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

Support for S3 "requester-pays" buckets #410

Closed
menshikh-iv opened this issue Jan 22, 2020 · 0 comments · Fixed by #411
Closed

Support for S3 "requester-pays" buckets #410

menshikh-iv opened this issue Jan 22, 2020 · 0 comments · Fixed by #411

Comments

@menshikh-iv
Copy link
Contributor

Problem:
I trying to open file s3://arxiv/pdf/arXiv_pdf_manifest.xml but get AccessDenied error.

This happens because of arxiv bucket is https://docs.aws.amazon.com/AmazonS3/latest/dev/RequesterPaysBuckets.html.

The idea is simple: you should pay for any queries to this bucket (not bucket owner). For this reason, in tools like awscli or s3cmd authors add --request-payer flag that confrims that you ready to pay money from your account for get access to bucket. For example, see aws/aws-cli#797.

Solution:
Typically, this argument named like {'RequestPayer': 'requester'} or {'x-amz-request-payer': 'requester'} (if we talking about boto3).
I can't pass "object_kwargs" to S3 connector, arguments resource_kwargs or multipart_upload_kwargs aren't suitable for this. For example, RequestPayer='requester' should be passed to any "get-like" method, here https://github.com/RaRe-Technologies/smart_open/blob/a621aebcb34069b0f7850784231c3eaac7e2b964/smart_open/s3.py#L143 and any s3_object.get call.

This code should show content of file after adding "object_kwargs" arguments (instead of exceptions)

from smart_open import open as smart_open

with smart_open("s3://arxiv/pdf/arXiv_pdf_manifest.xml", "r", object_kwargs={'RequestPayer': 'requester'}) as infile:
    print(infile.read())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant