yoshidan / google-cloud-rust

Google Cloud Client Libraries for Rust.
MIT License
233 stars 85 forks source link

Set content type #110

Closed PatrickHeneise closed 1 year ago

PatrickHeneise commented 1 year ago

Thanks for providing this library! I've managed to set up a file down- and upload based on your latest changes from today.

Is there a way to set the Content Type other than application/octet-stream based on the filename/extension?

yoshidan commented 1 year ago

Yes there is . You can set Content-Type as followoing code.

let mut media = Media::new("test1");
media.content_type = "text/plain".into();
let uploaded = client.upload_object(
       &UploadObjectRequest {
            bucket: bucket_name.to_string(),
             ..Default::default()
       },
        vec![1, 2, 3, 4, 5, 6], 
        UploadType::Simple(media), 
        None
).await;
PatrickHeneise commented 1 year ago

Thanks. Sorry for opening an issue, didn't think it was that easy.