I would like to do a pre-signed POST to upload files to an AWS S3 bucket - how would this be done in Go?
Please note that this is not the same as Pre-signed upload w
At a glance it looks like POST works with an attached policy and signature -- designed for browser based uploads. See the AWS Docs for details.
Specifically, you need to generate a policy and sign that -- then include them in the HTML form, and thereby the POST request -- along with the rest of the required information. Or let the browser do it for you.
In the case of HTML form POST uploads you are only signing the policy string. The final URL to be posted to can vary based on the form contents: https://bucket.s3.amazonaws.com/
. So you can't presign that URL because you don't know what it is.
This is different than a signed URL to which you PUT a file. You can sign that because you know the full URL: https://bucket.s3.amazonaws.com/known-key
You could build a POST request with the appropriate policy and parameters and upload via POST that way. However, you would need to know the contents of the form to know the URL beforehand. In which case you may as well use a presigned PUT URL.
At least that is how it appears at a glance...