Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: upload and delete files #1

Merged
merged 11 commits into from Jul 4, 2022
Merged

feat: upload and delete files #1

merged 11 commits into from Jul 4, 2022

Conversation

EstebanBorai
Copy link
Collaborator

First implementation on the ImageKit client with support for uploading
tokio::fs::File instances and also removal (delete) files from the File Storage
given the file id.


Working example:

use imagekit::ImageKit;
use imagekit::delete::Delete;
use imagekit::upload::types::FileType;
use imagekit::upload::{Options, Upload, UploadFile};
use tokio::fs::File;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let mut image_kit = ImageKit::new(
        "your_public_api_key",
        "your_private_api_key",
        "https://ik.imagekit.io/your_imagekit_id/",
    );

    // Upload an image from File
    let file = File::open("assets/ferris.jpeg").await.unwrap();
    let opts = Options::new(upload_file, "ferris");
    let upload_result = imagekit.upload(opts).await.unwrap();

    // Delete a file
    let delete_result = imagekit.delete(upload_result.file_id).await;
}

@EstebanBorai EstebanBorai merged commit 53517fb into main Jul 4, 2022
@EstebanBorai EstebanBorai deleted the feat/upload branch July 4, 2022 01:55
EstebanBorai pushed a commit that referenced this pull request May 24, 2023
feat: initialize client as part of `ImageKit` instance (#5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant