公式サイトには以下の用に書いてありますが、実際にやってみたら
cache-control ではなく
x-amz-meta-cache-control の値がついてしましました。
これでは、cache-control が効きません。
Uploading an Item with Metadata to an Amazon S3 Bucket - AWS SDK for Ruby
Upload an item with metadata to an Amazon S3 bucket using this AWS SDK for Ruby code example.
公式サイトのようにやるコード
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 = {cache_control: "no-cache, no-store"} # Upload it obj.upload_file(file, metadata: metadata)
正しくは以下のようにします。
upload_file()の引数を変えました。
このようにすると cache-control 属性がつきます。
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 = {cache_control: "no-cache, no-store"} # Upload it obj.upload_file(file, metadata)