简体   繁体   English

如何将子文件夹移动到同一个 s3 存储桶 boto3 中的另一个主文件夹?

[英]How can I move a sub-folder to another main folder within same s3 bucket boto3?

dst= s3.get_object(Bucket='bucket_name', ) copy_source = { 'Bucket': 'bucket_name', 'Key': 'folder_path' } dst.copy(copy_source,'Key': 'target_folder_path')

You will need to:您将需要:

  • Loop through a list of the objects to 'move' (you can specify a prefix with s3_resource.Bucket('bucket-name').objects.filter(Prefix='path/') )循环遍历要“移动”的对象列表(您可以使用s3_resource.Bucket('bucket-name').objects.filter(Prefix='path/')指定前缀)
  • For each object you wish to 'move':对于您希望“移动”的每个对象:
  • Use copy() to copy the object to the desired path使用copy()将对象复制到所需路径
  • Then delete() the source object然后delete()源对象

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用 Python boto3 获取 S3 中每个文件夹和子文件夹的大小 - Getting size of every folder and sub-folder in S3 using Python boto3 使用 boto3 将本地文件夹同步到 s3 存储桶 - Sync local folder to s3 bucket using boto3 使用 boto3 将文件上传到特定文件夹中的 s3 存储桶 - Using boto3 to upload files to s3 bucket within specific folder 在同一s3存储桶中使用boto3重命名密钥 - Rename key using boto3 within the same s3 bucket 使用 boto3 在 Amazon S3 上的文件夹之间移动文件 - Move files between folder on Amazon S3 using boto3 如何使用python boto3将文件上传到aws S3存储桶中的文件夹 - How to upload file to folder in aws S3 bucket using python boto3 如何使用条件为 python boto3 代码在 s3 存储桶中创建文件夹 - how to create a folder in s3 bucket by using python boto3 code for with conditions 如何使用 boto3 从 S3 存储桶中的文件夹中检索子文件夹和文件? - How to retrieve subfolders and files from a folder in S3 bucket using boto3? 如何使用 Python Boto3 列出和读取 S3 存储桶的特定文件夹中的每个文件 - How to list and read each of the files in specific folder of an S3 bucket using Python Boto3 将文件从一个 AWS s3 存储桶/文件夹复制到另一个 AWS/S3 文件夹,并通过 python 在数据块上保留最深的子文件夹名称 - copy files from one AWS s3 bucket/folder to another AWS/S3 folder and also keep the deepest sub-folder name by pythons on databricks
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM