英文:
AWS CLI for copying an older version of a file on s3
问题
你可以使用AWS命令行界面(awscli)将版本化的存储桶中的内容复制到S3本身。通常情况下,可以使用以下命令:
aws s3 cp from-loc to-loc
英文:
I have a versioned bucket. I know that I can download older versions, but can I also copy with the aws command line interface (awscli) to s3 itself? Normally this would be something
aws s3 cp from-loc to-loc
答案1
得分: 2
从 copy-object — AWS CLI命令参考 中,您可以使用以下命令:
aws s3api copy-object --bucket DESTINATION_BUCKET --key DESTINATION_FILENAME --copy-source 'SOURCE_BUCKET/SOURCE_FILENAME?versionId=VERSION_ID'
请注意,versionId
在 --copy-source
的末尾指定为:?versionId=...
我尝试过它,它正常工作:
$ aws s3api copy-object --bucket my_bucket --key version-output --copy-source 'my_bucket/IMG.jpg?versionId=OXxABkv6CbZ1TFY_oupeHRweEdBJa7_K'
{
"CopySourceVersionId": "OXxABkv6CbZ1TFY_oupeHRweEdBJa7_K",
"VersionId": "DJOCWGV79gq01WGVv4BIPIpfBDAPtYLI",
"ServerSideEncryption": "AES256",
"CopyObjectResult": {
"ETag": "\"cf0accb1b590bc16f3806b270a03132d\"",
"LastModified": "2023-06-06T08:13:50+00:00"
}
}
英文:
From copy-object — AWS CLI Command Reference you can use:
aws s3api copy-object --bucket DESTINATION_BUCKET --key DESTINATION_FILENAME --copy-source 'SOURCE_BUCKET/SOURCE_FILENAME?versionId=VERSION_ID'
Note that the versionId
is specified at the end of the --copy-source
with: ?versionId=...
I tried it and it worked correctly:
$ aws s3api copy-object --bucket my_bucket --key version-output --copy-source 'my_bucket/IMG.jpg?versionId=OXxABkv6CbZ1TFY_oupeHRweEdBJa7_K'
{
"CopySourceVersionId": "OXxABkv6CbZ1TFY_oupeHRweEdBJa7_K",
"VersionId": "DJOCWGV79gq01WGVv4BIPIpfBDAPtYLI",
"ServerSideEncryption": "AES256",
"CopyObjectResult": {
"ETag": "\"cf0accb1b590bc16f3806b270a03132d\"",
"LastModified": "2023-06-06T08:13:50+00:00"
}
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论