Can't set metadata when uplaoding file to S3 #976
-
When trying to upload a file as follows, the meta data provided doesn't populate correctly when inspecting the object in the console.
but instead I see
I've tried changing the keys in the hashmap for the metadata but to no avail, I can do this in other languages (e.g. python) just fine but I haven't figured out how to do this in rust. Any help would be greatly appreciated let client: aws_sdk_s3::Client = some_client;
let data: Bytes = some_data;
let key = "some_key";
let bucket = "some_bucket";
let meta_data = HashMap::from([
("Content-Type".into(), "image/jpeg".into()),
("Content-Disposition".into(), "inline".into()),
]);
let resp = client
.put_object()
.bucket(bucket)
.key(key)
.body(data.into())
.set_metadata(Some(meta_data))
.send()
.await
.unwrap(); |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
I think you need to set Let me know if that works. |
Beta Was this translation helpful? Give feedback.
-
Hello! Reopening this discussion to make it searchable. |
Beta Was this translation helpful? Give feedback.
I think you need to set
content_type
directly instead of setting it via Metadata: https://docs.rs/aws-sdk-s3/latest/aws_sdk_s3/operation/put_object/builders/struct.PutObjectFluentBuilder.html#method.content_type (same forcontent_disposition
Let me know if that works.