How can I change the S3 storage class of an Object / Directory using Ruby SDK?

570 views Asked by At

I cannot find a method comparable to the changeOutputStorageClass method from the Java SDK. I also have heard that there is a way to do this via AWS CLI, but I am trying to utilize the Ruby SDK.

1

There are 1 answers

0
strongjz On BEST ANSWER

Version 2 has it in the S3 object PutObjectRequest

object.put({
  acl: "private", # accepts private, public-read, public-read-write, authenticated-read, aws-exec-read, bucket-owner-read, bucket-owner-full-control
  body: source_file, # file/IO object, or string data
  cache_control: "CacheControl",
  content_disposition: "ContentDisposition",
  content_encoding: "ContentEncoding",
  content_language: "ContentLanguage",
  content_length: 1,
  content_md5: "ContentMD5",
  content_type: "ContentType",
  expires: Time.now,
  grant_full_control: "GrantFullControl",
  grant_read: "GrantRead",
  grant_read_acp: "GrantReadACP",
  grant_write_acp: "GrantWriteACP",
  metadata: {
    "MetadataKey" => "MetadataValue",
  },
  server_side_encryption: "AES256", # accepts AES256, aws:kms
  storage_class: "STANDARD", # accepts STANDARD, REDUCED_REDUNDANCY, STANDARD_IA
  website_redirect_location: "WebsiteRedirectLocation",
  sse_customer_algorithm: "SSECustomerAlgorithm",
  sse_customer_key: "SSECustomerKey",
  sse_customer_key_md5: "SSECustomerKeyMD5",
  ssekms_key_id: "SSEKMSKeyId",
  request_payer: "requester", # accepts requester
  tagging: "TaggingHeader",
  use_accelerate_endpoint: false,
})

http://docs.aws.amazon.com/sdkforruby/api/Aws/S3/Types/PutObjectRequest.html

and in the CopyObjectRequest

http://docs.aws.amazon.com/sdkforruby/api/Aws/S3/Types/CopyObjectRequest.html