问题
I'm trying to upload CSV files to Amazon S3.
I'm able to add metadata using the below code snippet:
s3_obj.upload_file(file_to_be_uploaded, {"content_type": "application/octet-stream"}
How can I add suitable tags (key-value pairs) -- for example exp: tag = { marked_to_delete: "true" } -- while uploading?
回答1:
You should be able to do that by passing tagging: "marked_to_delete=true" as an option.
Options are passed to an instance of AWS::S3::Client's put_object method. The docs give a similar example:
resp = client.put_object({
body: "filetoupload",
bucket: "examplebucket",
key: "exampleobject",
server_side_encryption: "AES256",
tagging: "key1=value1&key2=value2",
})
来源:https://stackoverflow.com/questions/49047085/add-tag-while-uploading-an-object-to-amazon-s3-in-rails