Skip to content

Commit

Permalink
pass RequestPayer when calling head_object() on s3 client
Browse files Browse the repository at this point in the history
  • Loading branch information
AdeelH committed May 2, 2024
1 parent 537c28e commit f36c1c2
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions rastervision_aws_s3/rastervision/aws_s3/s3_file_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,9 @@ def read_bytes(uri: str) -> bytes:
bucket, key = S3FileSystem.parse_uri(uri)
with io.BytesIO() as file_buffer:
try:
file_size = s3.head_object(
Bucket=bucket, Key=key)['ContentLength']
obj = s3.head_object(
Bucket=bucket, Key=key, RequestPayer=request_payer)
file_size = obj['ContentLength']
with progressbar(file_size, desc='Downloading') as bar:
s3.download_fileobj(
Bucket=bucket,
Expand Down Expand Up @@ -263,7 +264,9 @@ def copy_from(src_uri: str, dst_path: str) -> None:
request_payer = S3FileSystem.get_request_payer()
bucket, key = S3FileSystem.parse_uri(src_uri)
try:
file_size = s3.head_object(Bucket=bucket, Key=key)['ContentLength']
obj = s3.head_object(
Bucket=bucket, Key=key, RequestPayer=request_payer)
file_size = obj['ContentLength']
with progressbar(file_size, desc=f'Downloading') as bar:
s3.download_file(
Bucket=bucket,
Expand Down

0 comments on commit f36c1c2

Please sign in to comment.