bash - 如何使用 Amazon 的 s3api 重命名文件?
问题描述
我正在使用 Amazon 的 s3api 接口尝试重命名我已经上传到存储桶的文件(在 bash 脚本中完成)。我想运行命令
aws s3api --recursive mv s3://$bucket_name/$file_name s3://$bucket_name/$file_name.$last_modified_file_date
但显然有些事情发生了变化,因为上述内容因错误而死
usage: aws [options] <command> <subcommand> [<subcommand> ...] [parameters]
To see help text, you can run:
aws help
aws <command> help
aws <command> <subcommand> help
aws: error: argument operation: Invalid choice, valid choices are:
abort-multipart-upload | complete-multipart-upload
copy-object | create-bucket
create-multipart-upload | delete-bucket
如何重命名存储桶中存在的文件?
解决方案
您不能直接重命名 s3 中的文件,您唯一的选择是使用“mv”命令并为目标键使用新名称:
aws s3 --recursive mv s3://<bucket>/<old_key> s3://<bucket>/<new_key>
推荐阅读
- python - 检查数据框中的每一行和每一列并用用户定义函数替换值
- pdf - 使用 Chrome 检查在 Chrome 上编辑 PDF 中的文本
- django-models - 我怎样才能只使用 Django 用户模型的几个属性?
- javascript - 仅在鼠标悬停时加载 iframe
- c# - 如何使用 EF Core 中的基本 DbContext 类访问实体?
- r - 用 R 中的另一列更改索引列
- target-sdk - 带有 targetSDK 22 安全漏洞的 Android 7
- java - 将光标放在圆上时更改圆的位置
- rest - 休息 /me/items 与 /users/1/items
- node.js - 运行节点命令需要这么多时间