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

Remove copy_object !Send #103

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Remove copy_object !Send #103

wants to merge 1 commit into from

Conversation

mishi321
Copy link

change

Use #[async_recursion] instead of #[async_recursion(?Send)], which make minio::s3::client::Client::copy_object work on tokio::spwan and axum reqwuest handler. If we still need Sync here, may switch to #[async_recursion(Sync)].

async-recursion macro

#[async_recursion] modifies your function to return a boxed Future with a Send bound.
#[async_recursion(?Send)] modifies your function to return a boxed Future without a Send bound.
#[async_recursion(Sync)] modifies your function to return a boxed Future with a Send and Sync bound.

demo

This is a master branch demo with Send limit, can't compile.

use minio::s3::{
    args::{CopyObjectArgs, CopySource},
    creds::StaticProvider,
    Client,
};

#[tokio::main]
async fn main() {
    tokio::spawn(copy_image(
        "bucket_from",
        "bucket_to",
        "filename".to_owned(),
    ));
}

pub async fn copy_image(bucket_from: &str, bucket_to: &str, filename: String) {
    let client = Client::new(
        "Base_Url".parse().unwrap(),
        Some(Box::new(StaticProvider::new(
            "MINIO_ACCESS_KEY",
            "MINIO_SECRET_KEY",
            None,
        ))),
        None,
        None,
    )
    .unwrap();
    let args = CopyObjectArgs::new(
        bucket_to,
        &filename,
        CopySource::new(bucket_from, &filename).unwrap(),
    )
    .unwrap();
    let _ = client.copy_object(&args).await;
}

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.

1 participant