You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

在Windows 11 CMD执行AWS S3 put-object-tagging命令报错求助

解决Windows 11 CMD中AWS s3api put-object-tagging命令报错问题

问题场景

在Windows 11命令提示符(CMD)中执行AWS s3api put-object-tagging命令时持续报错,已确认桶名、对象名替换正确,且CLI用户拥有对应操作权限。

尝试的命令及报错

  1. 第一条命令:
aws s3api put-object-tagging --bucket my-bucket --key doc1.rtf --tagging '{"TagSet": [{ "Key": "designation", "Value": "confidential" }]}'

报错信息:

usage: aws [options] <command> <subcommand> [<subcommand> ...] [parameters]
To see help text, you can run:

  aws help
  aws <command> help
  aws <command> <subcommand> help

Unknown options: Key:, designation,, Value:, confidential, }]}', [{
  1. 第二条命令:
aws s3api put-object-tagging --bucket my-bucket --key doc1.rtf --tagging 'TagSet=[{Key=designation,Value=confidential}]'

报错信息:

Error parsing parameter '--tagging': Expected: '=', received: ''' for input:
'TagSet={Key=designation,Value=confidential}'
^

解决方案

Windows CMD不支持用单引号作为字符串边界,需将包裹--tagging参数值的单引号替换为双引号,同时处理内部的引号格式:

方式1:使用JSON格式参数

aws s3api put-object-tagging --bucket my-bucket --key doc1.rtf --tagging "{\"TagSet\": [{ \"Key\": \"designation\", \"Value\": \"confidential\" }]}"

方式2:使用AWS CLI简写格式

aws s3api put-object-tagging --bucket my-bucket --key doc1.rtf --tagging "TagSet=[{Key=designation,Value=confidential}]"

原因说明

Windows CMD仅识别双引号作为字符串的包裹符,之前使用单引号会导致CMD将参数内部的空格、逗号等字符当作命令的分隔符,进而被AWS CLI误解析为未知选项或格式错误。替换为双引号包裹整个参数值后,CMD会将其作为完整参数传递给AWS CLI,即可正常执行。

内容的提问来源于stack exchange,提问作者Arvind Kumar Avinash

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.19 13:02:20