Cannot get generate_presigned_post to work
Hi,
I am running S3Mock in a container. I try uploading a file there using pre-signed URL with boto3. In order to do so, I literally copy paste from the official tutorial:
https://boto3.amazonaws.com/v1/documentation/api/latest/guide/s3-presigned-urls.html#generating-a-presigned-url-to-upload-a-file
However, this ends up in a http return code 400
The server does not spit any error nor any message at all.
This is the presigned output I get, which seems quite legit:
{'url': u'http://s3-direct:9090/myFirstBucket', 'fields': {'policy': u'eyJjb25kaXRpb25zIjogW3siYnVja2V0IjogIm15Rmlyc3RCdWNrZXQifSwgeyJrZXkiOiAidGVzdFByZXNpZ25lZC5weSJ9XSwgImV4cGlyYXRpb24iOiAiMjAyMC0wMy0yOFQwMDozOTozN1oifQ==', 'AWSAccessKeyId': u'aws_access_key_id', 'key': 'testPresigned.py', 'signature': u'Hnb1No6c8bU0Mat62jApXL3IY/Q='}}
Any hint on how I could tackle that ? Thanks for your help, and thanks for this super useful product !! :-)
I am running into a similar issue, and the presigned urls works for me when actually using s3
2022-05-01 17:15:27.948 DEBUG 1 --- [tp1003693033-21] o.s.web.servlet.DispatcherServlet : POST "/bucket", parameters={multipart}
2022-05-01 17:15:27.990 DEBUG 1 --- [tp1003693033-21] o.s.w.s.m.m.a.HttpEntityMethodProcessor : Using 'application/x-www-form-urlencoded', given [application/x-www-form-urlencoded, application/xml] and supported [*/*]
2022-05-01 17:15:27.992 DEBUG 1 --- [tp1003693033-21] o.s.web.servlet.DispatcherServlet : Completed 400 BAD_REQUEST
I don't know the first thing about spring, but based on the debug logs and FileStoreController, this request isn't getting mapped to any handler. I tried to use a presigned put, but I can't get that to work with user-defined metadata either with S3Mock or S3.
Sorry, but S3Mock currently does not implement the generation of presigned URLs.
Darn, thanks for the information.
Well, I can do basic presigned put/get requests with S3Mock, should that not be possible?
You mean, if you add presigned parameters to a URL, you can request that against S3Mock? That is expected - those parameters are currently completely ignored.
#125 lists a bug where a HEAD is possible with presigned parameters allowing only a GET request.
ah, thanks for the clarification.
I wrote tests for all presigned requests, everything works as expected. Parameters are completely ignored, however. This is good enough to test happy cases in your integration. See readme for a full description.
@chaen what I did not realize is that the SDK you're using is generating the presigned URLs. You need to configure the SDK for path-style access, then the presigned URLs will work too. In the Java SDK, presigner and S3Client use different configurations.