Reputation: 81
I want to perform the same operation as below:
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)
But getting error message in aws cli
C:\Users\upratik>aws s3 cp "C:\Amedments\sharepoint.docx" s3://pubmgmt-poc/ --metadata = '{"answer" => "42"}'
Unknown options: '{answer,=
Any help will be appricated on this.
Upvotes: 2
Views: 3929
Reputation: 238209
Usually you add --metadata
to aws s3 cp as follows:
--metadata="answer=42"
This will add user-defined metadata to the object uploaded which starts with 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
For example:
I tested this on Linux, but don't see a reason why it would be different on Windows.
Upvotes: 4