1

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?

SRack
  • 11,495
  • 5
  • 47
  • 60
Veeresh Honnaraddi
  • 1,011
  • 1
  • 9
  • 20

1 Answers1

3

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", 
})
Jan Klimo
  • 4,643
  • 2
  • 36
  • 42