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

Uploading files using presigned url in af-south-1 #2728

Closed
vedantbajaj96 opened this issue Jan 17, 2021 · 2 comments
Closed

Uploading files using presigned url in af-south-1 #2728

vedantbajaj96 opened this issue Jan 17, 2021 · 2 comments
Assignees
Labels
closed-for-staleness guidance Question that needs advice or information.

Comments

@vedantbajaj96
Copy link

Unable to upload data using presigned url in af-south-1 region.

Steps to reproduce

s3_client = boto3.client('s3', region_name='af-south-1')
res = s3_client.generate_presigned_post(Bucket=bucket_name, Key=object_key)
http_response = requests.post(res['url'], data=url['fields'], files=files)

The response I get is IllegalLocationConstraintException. The af-south-1 location constraint is incompatible for the region specific endpoint this request was sent to.

The same code works with buckets in other regions.

Boto3 version - 1.16.56
Interestingly, the same code works with boto3 version < 1.12

@vedantbajaj96 vedantbajaj96 added the needs-triage This issue or PR still needs to be triaged. label Jan 17, 2021
@vedantbajaj96
Copy link
Author

Upon further inspection, it seems when i pass the endpoint url while generating the s3 client, it works then.

    s3_client = boto3.client('s3',region_name='af-south-1', endpoint_url='https://s3.af-south-1.amazonaws.com')

But I dont see this issue on older versions of boto3, or with some of the other regions.

@swetashre swetashre self-assigned this Jan 19, 2021
@swetashre
Copy link
Contributor

Amazon S3 uses the Domain Name System (DNS) to route requests to facilities that can process them. This system works effectively, but temporary routing errors can occur. If a request arrives at the wrong Amazon S3 location, Amazon S3 responds with a temporary redirect that tells the requester to resend the request to a new endpoint. If a request is incorrectly formed, Amazon S3 uses permanent redirects to provide direction on how to perform the request correctly.

For all Regions that launched after March 20, 2019, if a request arrives at the wrong Amazon S3 location, Amazon S3 returns an HTTP 400 Bad Request error. Basically this means s3 region re-director won't work for region launched after march 20, 2019.
That's why when you are specifying the exact endpoint_url it works. I hope it helps. Please let me know if you have any more questions.

@swetashre swetashre added guidance Question that needs advice or information. closing-soon This issue will automatically close in 4 days unless further comments are made. and removed needs-triage This issue or PR still needs to be triaged. labels Jan 27, 2021
@github-actions github-actions bot added closed-for-staleness and removed closing-soon This issue will automatically close in 4 days unless further comments are made. labels Jan 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-for-staleness guidance Question that needs advice or information.
Projects
None yet
Development

No branches or pull requests

2 participants