我正在關注關于 udemy 的教程,我正在嘗試使用 boto3 將 pandas 資料幀作為鑲木地板上傳到 s3 存盤桶。我使用 BytesIO 將資料幀轉換為鑲木地板,并嘗試將其上傳到我公開的 s3 存盤桶中。在執行時我遇到一個錯誤:
Parameter validation failed:
Missing required parameter in input: "Key"
Unknown parameter in input: "key", must be one of: ACL, Body, Bucket, CacheControl, ContentDisposition, ContentEncoding, ContentLanguage, ContentLength, ContentMD5, ContentType, ChecksumAlgorithm, ChecksumCRC32, ChecksumCRC32C, ChecksumSHA1, ChecksumSHA256, Expires, GrantFullControl, GrantRead, GrantReadACP, GrantWriteACP, Key, Metadata, ServerSideEncryption, StorageClass, WebsiteRedirectLocation, SSECustomerAlgorithm, SSECustomerKey, SSECustomerKeyMD5, SSEKMSKeyId, SSEKMSEncryptionContext, BucketKeyEnabled, RequestPayer, Tagging, ObjectLockMode, ObjectLockRetainUntilDate, ObjectLockLegalHoldStatus, ExpectedBucketOwner
我目前在 macOS monterey 12.6.1
這是代碼, df_all 是一個資料框:
key = 'xetra_daily_report_' datetime.today().strftime("%Y%m%d_%H%M%S") '.parquet'
out_buffer = BytesIO()
df_all.to_parquet(out_buffer, index = False)
bucket_target = s3.Bucket('name-bucket')
bucket_target.put_object(Body = out_buffer.getvalue(), key = key)
以下是我的存盤桶策略:
`
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": "*",
"Action": [
"s3:PutObject",
"s3:GetObject",
"s3:DeleteObject",
"s3:GetObjectAcl",
"s3:PutObjectAcl"
],
"Resource": [
"arn:aws:s3:::name-bucket",
"arn:aws:s3:::name-bucket/*",
"arn:aws:s3:::name-bucket/ "
]
}
]
}
`
uj5u.com熱心網友回復:
key應該是Key(python 區分大小寫):
bucket_target.put_object(Body = out_buffer.getvalue(), Key = key)
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/529200.html
