pub async fn upload_object(bucket_name: String, object_name: PathBuf, filename: PathBuf) {
let upload_object_args = UploadObjectArgs::new(&bucket_name, object_name.to_str().expect("路径不支持"), filename.to_str().expect("路径不支持")).unwrap();
let _ = MINIO_CLIENT.upload_object(&upload_object_args).await;
}
I'm prompted when I submit my upload method to tokio,The upload method does this. Other methods, such as remove_object and list_objects, do not have this problem。Maybe I'm using it the wrong way. I'd like some Pointers
error: future cannot be sent between threads safely
--> src\main.rs:160:45
|
160 | return Command::perform(minio_util::upload_object(self.curr_bucket.clone(), object_name, file), |_| Message::Refresh);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ future returned by `upload_object` is not `Send`
|
= help: the trait `Sync` is not implemented for `dyn Sse`
note: future is not `Send` as this value is used across an await
--> src\minio_util.rs:92:61
|
90 | let upload_object_args = UploadObjectArgs::new(&bucket_name, object_name.to_str().expect("路径不支持"), filename.to_str().expect("路径不 ...
| ------------------ has type `UploadObjectArgs<'_>` which is not `Send`
91 | // let upload_object_args = UploadObjectArgs::new(&bucket_name, object_name.to_str().expect(""), &filename).unwrap();
92 | let _ = MINIO_CLIENT.upload_object(&upload_object_args).await;
| ^^^^^ await occurs here, with `upload_object_args` maybe used later
...
95 | }
| - `upload_object_args` is later dropped here
note: required by a bound in `iced::Command::<T>::perform`
--> C:\Users\17274\.cargo\git\checkouts\iced-3815be7e76d03e0b\8d77971\runtime\src\command.rs:43:53
|
42 | pub fn perform<A>(
| ------- required by a bound in this associated function
43 | future: impl Future<Output = T> + 'static + MaybeSend,
| ^^^^^^^^^ required by this bound in `Command::<T>::perform`