Skip to content

enigma-137/image-cdn

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Image CDN Uploader

A simple command-line tool to upload images to Cloudinary CDN.

Features

  • Upload images to Cloudinary directly from the command line
  • Supports various image formats (JPEG, PNG, GIF, etc.)
  • Simple and easy to use

Prerequisites

  • Rust (1.70 or later)
  • Cargo (comes with Rust)
  • A Cloudinary account

Setup

  1. Clone the repository

    git clone <repository-url>
    cd image-cdn
  2. Create a .env file

    Create a .env file in the project root directory with your Cloudinary credentials:

    CLOUDINARY_CLOUD_NAME=your_cloud_name
    CLOUDINARY_API_KEY=your_api_key
    CLOUDINARY_API_SECRET=your_api_secret

    You can find these credentials in your Cloudinary dashboard.

  3. Configure an upload preset (optional)

    • Go to your Cloudinary Dashboard → Settings → Upload
    • Add an upload preset (e.g., ml_default)
    • Set it to "Unsigned" mode for simpler uploads
    • Or remove the upload_preset from the code and use signed uploads

Usage

Run the uploader with an image path:

cargo run -- <path-to-image>

Examples

# Upload a single image
cargo run -- "C:\Users\ENIGMA\Downloads\photo.jpg"

# On Linux/Mac
cargo run -- "/home/user/images/photo.png"

Project Structure

image-cdn/
├── .env               # Environment variables (create this)
├── .gitignore         # Git ignore rules
├── Cargo.toml         # Rust dependencies
├── Cargo.lock         # Locked dependencies
├── README.md          # This file
└── src/
    └── main.rs        # Main application code

Dependencies

  • reqwest - HTTP client for making requests to Cloudinary
  • tokio - Async runtime for Rust
  • serde - Serialization/deserialization
  • dotenv - Load environment variables from .env file

Development

Build

cargo build

Run

cargo run -- <image-path>

Release Build

cargo build --release

The optimized binary will be in target/release/image-cdn.exe.

Troubleshooting

"api_key not provided" error

Make sure your .env file is in the project root directory and contains the correct credentials:

CLOUDINARY_CLOUD_NAME=your_cloud_name
CLOUDINARY_API_KEY=your_api_key
CLOUDINARY_API_SECRET=your_api_secret

"File not found" error

Ensure the image path you provide exists and is accessible.

Upload fails

  • Check your Cloudinary credentials
  • Verify your upload preset exists and is configured correctly
  • Make sure your Cloudinary account has API access enabled

Contributing

Contributions are welcome! Here's how you can help:

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/my-feature
  3. Make your changes and commit them
  4. Push to your branch: git push origin feature/my-feature
  5. Create a Pull Request

Coding Standards

  • Follow Rust's standard coding conventions
  • Use cargo fmt to format code before committing
  • Use cargo clippy to check for common mistakes
  • Add comments for complex logic

License

MIT License - feel free to use this project for any purpose.

Acknowledgments

  • Cloudinary for their image CDN service
  • Rust community for excellent documentation

About

A simple command-line tool to upload images to Cloudinary CDN.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages