Fork me on GitHub
#aws
<
2021-04-06
>
mlimotte17:04:52

Hi. I’m using the aws-api to upload a file to S3, and I want to set the Content-Type. I converted a java example I found to roughly this code:

(let [md       {"content-type" "text/plain"}
      response (core/throw-on-error
                 (aws/invoke client
                             {:op      :PutObject
                              :request {:Bucket   ""
                                        :Key      "marc/foo2.txt"
                                        :Body     (-> "some text" (.getBytes "UTF-8") (ByteArrayInputStream.))
                                        :Metadata md}}))]
  (:Body response))
But this is not working. When I check out the newly uploaded file in Amazon, I see: • System defined, Content-Type , application/octet-stream • User defined, x-amz-meta-content-type, text/plain So, instead of setting the system defined “Content-Type”, it stuffed my value into x-amz-meta-content-type . Any suggestions?

ghadi17:04:09

(aws/doc client :PutObject) call that @mlimotte and check out the :ContentType option

ghadi17:04:30

content type might be special in that it won't appear in Metadata

mlimotte19:04:54

@ghadi Yep--- that resolved the issue. Was not aware of that divergence from the java sdk. Thanks.

ghadi19:04:38

aws-api is generated from descriptor files, which is similar to how the java v2 sdk is generated (but java v1 sdk is ad hoc)