![](/img/trans.png)
[英]How to convert JSON to CSV file from s3 and save it in same s3 bucket using Glue job
[英]How to save a file in a folder within a S3 bucket using Flask?
我嘗試將圖像保存在我的 s3 存儲桶內的文件夾中,但它始終保存在存儲桶的根目錄中,而不是文件夾中。 這是我的代碼的樣子:
s3 = boto3.client(
"s3",
aws_access_key_id = Config.S3_ACCESS_KEY,
aws_secret_access_key = Config.S3_SECRET_ACCESS_KEY
)
def upload_file_to_s3(file, acl="public-read"):
try:
s3.upload_fileobj(
file,
Config.S3_BUCKET,
file.filename,
ExtraArgs={
"ACL": acl,
"ContentType": file.content_type
}
)
except Exception as e:
print("Something happened: ", e)
return e
return f"{ Config.S3_DOMAIN }profiles_name/{ file.filename }"
Profiles_name 是文件夾的名稱。 我該怎么做?
它應該適合你:
s3.upload_fileobj(
file,
Config.S3_BUCKET,
f"path/to/folder/within/bucket/{file.filename}",
ExtraArgs={
"ACL": acl,
"ContentType": file.content_type
}
)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.