Open fabiob opened 5 days ago
@fabiob which URL are you trying to POST to?
The controllers are annotated with @CrossOrigin(origins = "*", exposedHeaders = "*")
which means that the HTTP methods allowed default to the HTTP method declared by the controller function.
There are only a few S3 APIs that allow POST requests, most APIs use PUT to modify or create data.
The only APIs supported by S3Mock using POST are deleteObjects, createMultipartUpload and completeMultipartUpload.
The reason why your test fails is because the URL used points to a bucket (https://github.com/fabiob/S3Mock/commit/c7679fc8d8c84e3c7378f49f2d69741a6c71f7eb#diff-830d0afe6486c2b436b422fabcb308511dab2b2eef4c1edf698108716a4d7b0dR228), and there are no APIs that allow a POST on a bucket.
if you change your test to use "PUT" instead, it succeeds, as there are two APIs (and controller functions) that allow a "PUT" on a bucket, for example putObjectLockConfiguration
You write "upload file" - do you mean "putObject"? This API needs a "PUT", not a "POST" request: https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutObject.html
Hi! I'm migrating some of our tests from Localstack to S3Mock (great work, btw!), but I've encountered an issue where one of our tests fails when uploading a file to S3Mock using a presigned POST URL.
The request includes the
Access-Control-Allow-Methods: POST
header, and this seems to cause the failure. I've tried reproducing the issue, and you can see the failing test case here: https://github.com/fabiob/S3Mock/commit/c7679fc8d8c84e3c7378f49f2d69741a6c71f7ebWhat I've tried:
@CrossOrigin(..., methods = {Request.POST, ...})
to the controllers: https://github.com/fabiob/S3Mock/commit/79057ce74010360a59ae787a82df2b34569b5668@CrossOrigin
annotations from the controllers and tried configuring CORS globally by overridingS3MockConfiguration.addCorsMappings
: https://github.com/fabiob/S3Mock/commit/0c6d2c4a3e917368ffa35210d777769ae07032cb@CrossOrigin
annotations and added a CORS filter usingFilterRegistrationBean
toS3MockConfiguration
: https://github.com/fabiob/S3Mock/commit/ebe7d5e363dec5a6fb469c315c883744a00a348dNone of these attempts seem to resolve the issue. The test still fails when performing the
OPTIONS
request.Any insights or workarounds from others who may have experienced this issue would be greatly appreciated!
References I've used: