I am using presigned URLs to upload files (urls are generated via Go code), is there a way to enforce a certain content type and make the uploaded file public for reads prior or after upload?

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
1 answer

Hello,

You can, for both and they would need to add those parameters to the code, for example here is the Go SDK for uploading; let me see if I can find an example where params has been added too.

Refer to below link:

https://www.digitalocean.com/docs/spaces/resources/s3-sdk-examples/#generate-a-pre-signed-url-to-upload-a-file

eg like this curl(but same thing in the Go code in needed), it has a header for content-type:

curl -X PUT \
-H “Content-Type: text” \
-d “The contents of the file.” \
https://example-space-name.nyc3.digitaloceanspaces.com/new-file.ext?AWSAccessKeyId=EXAMPLE7UQOTHDTF3GK4&Content-Type=text&Expires=1580419378&Signature=YIXPlynk4BALXE6fH7vqbnwjSEw%3D

Few more links, which will likely be helpful too:

https://docs.ceph.com/en/latest/radosgw/s3/
https://github.com/awsdocs/aws-doc-sdk-examples/blob/master/go/example_code/s3/s3_put_bucket_object_acl.go

Hope this helps!

Cheers,
Sri Charan

Submit an Answer