Closed ranger-ross closed 11 months ago
data
type must be Into<Body>
. Therefore, it is necessary to use &static str
, String
, Bytes
, etc.
https://docs.rs/reqwest/latest/reqwest/struct.Body.html#trait-implementations
async fn run_simple(client:Client, data: String) {
let upload_type = UploadType::Simple(Media::new("filename"));
let result = client.upload_object(&UploadObjectRequest{
bucket: "bucket".to_string(),
..Default::default()
}, data, &upload_type).await;
}
I see, using String as the datatype works.
Sorry for the nooby question, I should have looked more closely at Into<Body>
and how it functions.
Thank you so much
First, thanks for creating this library its very helpful.
I am trying to use
client.upload_object()
to upload some data to Cloud Storage. However I am running into some lifetime issue with thedata: T
field where my data does not live long enough.In the documentation the example use a hardcoded
"hello world".as_bytes()
. But when I try to make the String dynamic I run into lifetime issues. Here is a simple example (modified from example in the docs)This code does not compile due to lifetime issues.
Sorry if this is a nooby question with an obvious answer. I am still fairly new to Rust, perhaps adding another example would make it more obvious how to use
upload_object
with non'static
data