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

Multipart file downloads PR#332 fails with access denied error on requester pays bucket #351

Open
woodcockr opened this issue Oct 26, 2024 · 2 comments

Comments

@woodcockr
Copy link

  • Async AWS SDK for Python version: 13.x
  • Python version: 3.12
  • Operating System: Ubuntu 24.04

Description

Download a file over s3 from a public requester pays bucket.

aioboto3 13.x Throw ClientError exception with Access Denied error.
Normal download using boto3 (no async) works as expected.
aioboto3 <13.0 works as expected.

What I Did

import aiofiles
import boto3
import aioboto3
import asyncio

s3 = boto3.client('s3')

async def download_file():
  session = aioboto3.Session()
  async with session.client('s3') as s3:
    async with aiofiles.open('test_file.tif', 'wb') as data:
      await s3.download_fileobj(
        Bucket='usgs-landsat',
        Key='collection02/level-1/standard/oli-tirs/2023/090/079/LC08_L1TP_090079_20230124_20230207_02_T1/LC08_L1TP_090079_20230124_20230207_02_T1_B6.TIF',
        Fileobj=data,
        ExtraArgs={"RequestPayer": "requester"}
      )

def download_file_sync():
  with open('test_file_sync.tif', 'wb') as data:
    s3.download_fileobj(
      Bucket='usgs-landsat',
      Key='collection02/level-1/standard/oli-tirs/2023/090/079/LC08_L1TP_090079_20230124_20230207_02_T1/LC08_L1TP_090079_20230124_20230207_02_T1_B6.TIF',
      Fileobj=data,
      ExtraArgs={"RequestPayer": "requester"}
    )

# To run the sync function
download_file_sync()

# To run the async function
asyncio.run(download_file())

I'm not familiar with the aioboto3 code base but wondered if this line was missing some ExtraArgs, to add the RequestPayer='requester' get_object appears to require?

@woodcockr woodcockr changed the title Multipart file downloasd #332 fails with access denied error on requester pays bucket Multipart file downloads #332 fails with access denied error on requester pays bucket Oct 26, 2024
@woodcockr woodcockr changed the title Multipart file downloads #332 fails with access denied error on requester pays bucket Multipart file downloads PR#332 fails with access denied error on requester pays bucket Oct 26, 2024
@terricain
Copy link
Owner

Can you test out this, that should fix it for you. If so I'll merge it in

@woodcockr
Copy link
Author

Passes the test now. Thank you.

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

No branches or pull requests

2 participants