[英]Not able to download files from S3 bucket?
這是我用來從S3存儲桶下載所有文件的代碼是:
#Download all files from a bucket to a local folder
LOCAL_PATH = "C\\s3\\"
bucket_name = 'unrendered'
# connect to the bucket
bucket = conn.get_bucket(bucket_name)
# go through the list of files
for key in bucket.list():
try:
res = key.get_contents_to_filename(key.name).replace("\\", "//")
except:
print(key.name+":"+"FAILED")
我的S3存儲桶中的文件是:
該代碼僅下載第一個文件,但我無法下載名稱包含目錄地址的其余文件。
另外,當我使用boto在S3上上傳文件時,它不會創建目錄,而是創建包含目錄名稱的文件。 我知道s3是平面數據結構,但是如何從Web界面創建文件夾。
在第9行中,嘗試用以下代碼替換行:
res = key.get_contents_to_filename(key.name.replace("\\", ""))
那樣有用嗎?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.