Object storage - howto change content type

#1

How can I change the content type of a file using the API ?

I can change it using cyberduck but could not find how to change it using other tools.

#2

awscli will usually set the correct one automatically upon upload:

➜  ~ aws --profile ams s3 cp warp_logo.png s3://dem0/warp_logo.png --acl public-read
upload: ./warp_logo.png to s3://dem0/warp_logo.png
➜  ~ curl -sI https://s3.nl-ams.scw.cloud/dem0/warp_logo.png | grep Content-Type
Content-Type: image/png

But you can specify it:

➜  ~ aws --profile ams s3 cp warp_logo.png s3://dem0/warp_logo.png --content-type text/plain --acl public-read
upload: ./warp_logo.png to s3://dem0/warp_logo.png
➜  ~ curl -sI https://s3.nl-ams.scw.cloud/dem0/warp_logo.png | grep Content-Type
Content-Type: text/plain

You can update an existing object using a server-side copy:

➜  ~ aws --profile ams s3 cp s3://dem0/warp_logo.png s3://dem0/warp_logo.png --content-type application/octet-stream --acl public-read
copy: s3://dem0/warp_logo.png to s3://dem0/warp_logo.png
➜  ~ curl -sI https://s3.nl-ams.scw.cloud/dem0/warp_logo.png | grep Content-Type
Content-Type: application/octet-stream

This operation is usually available on all S3 clients.

Hope that helps!