英文:
Having error when downloading the ZIP file from the S3-Bucket
问题
当我尝试从S3存储桶下载ZIP文件时,出现了一些错误。
我的代码
import boto3
client = boto3.client('s3')
bucket = 'picarro-da-gis'
file = 'ReteGasBari/10082021/Incoming/20211008_ReteGasBari.zip'
filename = '/Users/vithushan/Desktop/S3-Downloads/'
# 下载ZIP文件
client.download_file(
Bucket=bucket,
Key=file,
Filename=filename
)
我的错误
File "/Users/vithushan/Desktop/S3-Connect-Automation/zip_download.py", line 12, in <module>
client.download_file(
File "/Users/vithushan/Desktop/S3-Connect-Automation/s3-Env/lib/python3.11/site-packages/boto3/s3/inject.py", line 190, in download_file
return transfer.download_file(
^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/vithushan/Desktop/S3-Connect-Automation/s3-Env/lib/python3.11/site-packages/boto3/s3/transfer.py", line 326, in download_file
future.result()
File "/Users/vithushan/Desktop/S3-Connect-Automation/s3-Env/lib/python3.11/site-packages/s3transfer/futures.py", line 103, in result
return self._coordinator.result()
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/vithushan/Desktop/S3-Connect-Automation/s3-Env/lib/python3.11/site-packages/s3transfer/futures.py", line 266, in result
raise self._exception
File "/Users/vithushan/Desktop/S3-Connect-Automation/s3-Env/lib/python3.11/site-packages/s3transfer/tasks.py", line 139, in __call__
return this._execute_main(kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/vithushan/Desktop/S3-Connect-Automation/s3-Env/lib/python3.11/site-packages/s3transfer/tasks.py", line 162, in _execute_main
return_value = this._main(**kwargs)
^^^^^^^^^^^^^^^^^^^^
File "/Users/vithushan/Desktop/S3-Connect-Automation/s3-Env/lib/python3.11/site-packages/s3transfer/download.py", line 673, in _main
osutil.rename_file(fileobj.name, final_filename)
File "/Users/vithushan/Desktop/S3-Connect-Automation/s3-Env/lib/python3.11/site-packages/s3transfer/utils.py", line 284, in rename_file
rename_file(current_filename, new_filename)
IsADirectoryError: [Errno 21] Is a directory: '/Users/vithushan/Desktop/S3-Downloads/.b3aAB3c8' -> '/Users/vithushan/Desktop/S3-Downloads/'
可以有人帮助我吗?
我需要通过路径从S3存储桶下载ZIP文件。
英文:
When I am trying to download the ZIP files from the S3 buckets it is showing some error
My Code
import boto3
client = boto3.client('s3')
bucket = 'picarro-da-gis'
file = 'ReteGasBari/10082021/Incoming/20211008_ReteGasBari.zip'
filename = '/Users/vithushan/Desktop/S3-Downloads/'
# Downloading ZIP file
client.download_file(
Bucket=bucket,
Key=file,
Filename=filename
)
My error
File "/Users/vithushan/Desktop/S3-Connect-Automation/zip_download.py", line 12, in <module>
client.download_file(
File "/Users/vithushan/Desktop/S3-Connect-Automation/s3-Env/lib/python3.11/site-packages/boto3/s3/inject.py", line 190, in download_file
return transfer.download_file(
^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/vithushan/Desktop/S3-Connect-Automation/s3-Env/lib/python3.11/site-packages/boto3/s3/transfer.py", line 326, in download_file
future.result()
File "/Users/vithushan/Desktop/S3-Connect-Automation/s3-Env/lib/python3.11/site-packages/s3transfer/futures.py", line 103, in result
return self._coordinator.result()
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/vithushan/Desktop/S3-Connect-Automation/s3-Env/lib/python3.11/site-packages/s3transfer/futures.py", line 266, in result
raise self._exception
File "/Users/vithushan/Desktop/S3-Connect-Automation/s3-Env/lib/python3.11/site-packages/s3transfer/tasks.py", line 139, in __call__
return self._execute_main(kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/vithushan/Desktop/S3-Connect-Automation/s3-Env/lib/python3.11/site-packages/s3transfer/tasks.py", line 162, in _execute_main
return_value = self._main(**kwargs)
^^^^^^^^^^^^^^^^^^^^
File "/Users/vithushan/Desktop/S3-Connect-Automation/s3-Env/lib/python3.11/site-packages/s3transfer/download.py", line 673, in _main
osutil.rename_file(fileobj.name, final_filename)
File "/Users/vithushan/Desktop/S3-Connect-Automation/s3-Env/lib/python3.11/site-packages/s3transfer/utils.py", line 284, in rename_file
rename_file(current_filename, new_filename)
IsADirectoryError: [Errno 21] Is a directory: '/Users/vithushan/Desktop/S3-Downloads/.b3aAB3c8' -> '/Users/vithushan/Desktop/S3-Downloads/'
Can anyone help for me?
I need to download the ZIP file from the S3 bucket using path
答案1
得分: 1
Your filename
points to a directory. You need to add a specific filename for the downloaded object:
import boto3
client = boto3.client('s3')
bucket = 'picarro-da-gis'
file = 'ReteGasBari/10082021/Incoming/20211008_ReteGasBari.zip'
filename = '/Users/vithushan/Desktop/S3-Downloads/downloaded.zip'
# Downloading ZIP file
client.download_file(
Bucket=bucket,
Key=file,
Filename=filename
)
英文:
Your filename
points to a directory. You need to add a specific filename for the downloaded object:
import boto3
client = boto3.client('s3')
bucket = 'picarro-da-gis'
file = 'ReteGasBari/10082021/Incoming/20211008_ReteGasBari.zip'
filename = '/Users/vithushan/Desktop/S3-Downloads/downloaded.zip'
# Downloading ZIP file
client.download_file(
Bucket=bucket,
Key=file,
Filename=filename
)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论