I'm currently using the AWS javascript SDK to create pre-signed POST's. (note that this question is NOT about pre-signed PUTs/URLs, another s3 feature)
https://github.com/aws/aws-sdk-js/
When trying to create a pre-signed post I do something like the following:
const params = {
Bucket: 'myuniques3bucket',
Fields: {
Key: 'key1.png',
'Content-Type': 'image/png'
},
conditions: [
{bucket: 'myuniques3bucket'},
{key: 'key1.png'},
{'Content-Type': 'image/png'},
['content-length-range', 1024, 1048576], // 1KB to 10MB
{'x-amz-date': amzDate},
{'x-amz-algorithm': 'AWS4-HMAC-SHA256'},
{'x-amz-credential': `${process.env.AWS_ACCESS_KEY_ID}/20180820/us-east-2/s3/aws4_request`}
],
Expires: 300 // 300 seconds
}
s3.createPresignedPost(params, (err, data) => {
console.log(data);
});
And I'm wrapping tests around the upload processes that should not work. I'm finding that the content type is not enforced there as I can upload other file types with other content-type post params.
It's not clear to me whether the JS SDK manages the signing process for the user or if I need to do something special to get these various keys in the signature.
It's clear that I CAN do some of this, it's not clear if I NEED to. Not sure if the library is supposed to be handling that for me.
TLDR; What do I need to do to activate content-type validation with s3 pre-signed POST's using the js sdk?
Any help would be greatly appreciated.