gpt4 book ai didi

amazon-web-services - 使用 aws cli 将带有元数据的项目上传到 Amazon S3 存储桶

转载 作者:行者123 更新时间:2023-12-04 09:37:15 32 4
gpt4 key购买 nike

我想执行与下面相同的操作:
https://docs.aws.amazon.com/sdk-for-ruby/v3/developer-guide/s3-example-upload-bucket-item-with-metadata.html

require 'aws-sdk-s3'  # v2: require 'aws-sdk'

s3 = Aws::S3::Resource.new(region: 'us-west-2')

file = 'C:\file.txt'
bucket = 'my-bucket'

# Get just the file name
name = File.basename(file)

# Create the object to upload
obj = s3.bucket(bucket).object(name)

# Metadata to add
metadata = {"answer" => "42"}

# Upload it
obj.upload_file(file, metadata: metadata)
但是在 aws cli 中收到错误消息
C:\Users\upratik>aws s3 cp "C:\Amedments\sharepoint.docx" s3://pubmgmt-poc/ --metadata = '{"answer" => "42"}'
未知选项:'{answer,=
将对此提供任何帮助。

最佳答案

通常你加--metadataaws s3 cp如下:

--metadata="answer=42" 
这将添加 user-defined metadata到以 x-amz-meta 开头的上传对象:

When you upload objects using the REST API, the optional user-defined metadata names must begin with "x-amz-meta-" to distinguish them from other HTTP headers


例如:
enter image description here
我在 Linux 上对此进行了测试,但没有看到它在 Windows 上会有所不同的原因。

关于amazon-web-services - 使用 aws cli 将带有元数据的项目上传到 Amazon S3 存储桶,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62513009/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com