Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We've had an issue since the LocalStack PR: localstack/localstack#10616, raised by @thrau
We've added better validation of S3 POST policy conditions, and some SDK set them automatically like in this case.
But when creating and passing the form, we would not forward all the fields created by the pre-signed POST, so the validation would fail.
I've also created an AWS validated test here: localstack/localstack#10641
To validate that LocalStack handles it correctly (we might return some different exceptions in case of invalid credentials, but that's alright for now). Anyway, AWS does not ignore any fields and will fail as well if we would try to do what the sample does at the moment.
I've created the form manually and appended the fields to it:
https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest_API/Using_FormData_Objects
The
file
field needs to be last, so I've created the form from scratch instead of using the element to fetch it. Otherwise, we would need to create hidden fields in the form for every field returned by the pre-signed.Also see https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-s3-presigned-post/ for the pre-signed POST doc on how you can use it in browser.
I've also sneaked a fix to properly delete the build image when running on macOS.
Also did a quick S3 change in the lambda creating the pre-signed, as we would always call
create_bucket
to check the bucket exists, but this is only omnipotent inus-east-1
and would raise an exception if done in any other region, so I've did it withhead_bucket
instead.