我需要重命名 AWS S3 存储桶中存储的大量文件。每个文件/对象将单独重命名(基于特定标准 - 没有通用的“前缀/后缀”)。我想出了“current_filename”和“new_filename”的列表,它们可以作为 .bat 文件/队列在 CLI 中执行。
是否可以通过 CLI 或以编程方式仅更新 AWS S3 存储桶中的对象键(键名称),而无需复制/移动文件,如下所示:
aws s3 cp s3://mybucket/folder/myfilename.jpg s3://mybucket/folder/my_NEW_filename.jpg
我可以保持所有其他对象元数据相同,但文件名(键名)必须更改。
您还可以使用 AWS S3 Move 命令将文件移动到新名称,而不是复制和删除文件。AWS S3 移动 http://docs.aws.amazon.com/cli/latest/reference/s3/mv.html
# AWS Example
aws s3 mv s3://mybucket/test.txt s3://mybucket/test2.txt
# Copy file from local to S3
aws s3 cp robots.txt s3://ascisolutions.com
# Rename/move file
aws s3 mv s3://ascisolutions.com/robots.txt s3://ascisolutions.com/robots.txt.bak
# Move file to a directory in S3
aws s3 mv s3://ascisolutions.com/robots.txt.bak s3://ascisolutions.com/test/robots.txt.bak
# Rename/move file
aws s3 mv s3://ascisolutions.com/test/robots.txt.bak s3://ascisolutions.com/test/robots.txt
# Move file back to root directory of S3 bucket
aws s3 mv s3://ascisolutions.com/test/robots.txt s3://ascisolutions.com/robots.txt
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)