我使用的是boto3,有两个s3存储桶:
source s3 bucket: 'final-files'
destination s3 bucket: 'exchange-files'
prefix for destination s3 bucket: 'timed/0001'
key: final_file[-1]
我需要将一个文件从源bucket复制到目标bucket中的文件夹,我不确定如何将前缀添加到目标;这是我的代码:
#create a source dictionary that specifies bucket name and key name of the object to be copied
copy_source = {
'Bucket': 'final-files',
'Key': final_file[-1]
}
bucket = s3.Bucket('exchange-files')
prefix="timed/0001"
bucket.copy(copy_source, prefix + key)
# Printing the Information That the File Is Copied.
print('Single File is copied')
这是我得到的错误:
"errorMessage": "expected string or bytes-like object, got 's3.Bucket'"
我错过了什么?