Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot get generate_presigned_post to work #219

Closed
chaen opened this issue Mar 27, 2020 · 9 comments · Fixed by #1285
Closed

Cannot get generate_presigned_post to work #219

chaen opened this issue Mar 27, 2020 · 9 comments · Fixed by #1285
Labels

Comments

@chaen
Copy link

chaen commented Mar 27, 2020

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 !! :-)

@jfarshankar
Copy link

I am running into a similar issue, and the presigned urls works for me when actually using s3

@jfarshankar
Copy link

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.

@afranken
Copy link
Member

afranken commented May 2, 2022

Sorry, but S3Mock currently does not implement the generation of presigned URLs.

@jfarshankar
Copy link

Darn, thanks for the information.

@jfarshankar
Copy link

Well, I can do basic presigned put/get requests with S3Mock, should that not be possible?

@afranken
Copy link
Member

afranken commented May 3, 2022

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.

@jfarshankar
Copy link

ah, thanks for the clarification.

afranken added a commit that referenced this issue Aug 8, 2023
AWS SDKs need to be configured with path-style access, CLI with
"endpoint", HTTP access works as well.
Presigned URIs can be created against S3Mock when enforcing path-style
access in the S3Presigner.
S3Mock ignores all parameters for presigned URIs and just serves the
request.

Fixes #219, #125, #1196
afranken added a commit that referenced this issue Aug 8, 2023
AWS SDKs need to be configured with path-style access, CLI with
"endpoint", HTTP access works as well.
Presigned URIs can be created against S3Mock when enforcing path-style
access in the S3Presigner.
S3Mock ignores all parameters for presigned URIs and just serves the
request.

Fixes #219, #125, #1196
afranken added a commit that referenced this issue Aug 15, 2023
AWS SDKs need to be configured with path-style access, CLI with
"endpoint", HTTP access works as well.
Presigned URIs can be created against S3Mock when enforcing path-style
access in the S3Presigner.
S3Mock ignores all parameters for presigned URIs and just serves the
request.

Fixes #219, #125, #1196
afranken added a commit that referenced this issue Aug 15, 2023
AWS SDKs need to be configured with path-style access, CLI with
"endpoint", HTTP access works as well.
Presigned URIs can be created against S3Mock when enforcing path-style
access in the S3Presigner.
S3Mock ignores all parameters for presigned URIs and just serves the
request.

Fixes #219, #125, #1196
@afranken
Copy link
Member

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.

@afranken
Copy link
Member

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants