我需要将文件从一个文件夹复制到 s3 存储桶的根目录。是否有一种通用方法可以提供空的目标键。或者我应该遵循以下复制和删除方法:
import boto3
s3_resource = boto3.resource(‘s3’)
# Copy object A as object B
s3_resource.Object(“bucket_name”, “newpath/to/object_B.txt”).copy_from(
CopySource=”path/to/your/object_A.txt”)
# Delete the former object A
s3_resource.Object(“bucket_name”, “path/to/your/object_A.txt”).delete()