From 401acb201fa1eba8b5dbbfdc74809c80377cb3c9 Mon Sep 17 00:00:00 2001 From: Julik Tarkhanov Date: Sun, 13 Sep 2015 14:17:52 +0200 Subject: [PATCH] Fix storage class setting on PresignedPost Previously storage_class would be passed as a vanilla form field which would be ignored by S3. The field should be passed as an "x-amz-storage-class" which requires a minimal change in the class descriptor. Once the field is set, the storage class is properly set on the POSTed object. --- .../lib/aws-sdk-resources/services/s3/presigned_post.rb | 2 +- aws-sdk-resources/spec/services/s3/presigned_post_spec.rb | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/aws-sdk-resources/lib/aws-sdk-resources/services/s3/presigned_post.rb b/aws-sdk-resources/lib/aws-sdk-resources/services/s3/presigned_post.rb index 243b7579271..5871f58ae3c 100644 --- a/aws-sdk-resources/lib/aws-sdk-resources/services/s3/presigned_post.rb +++ b/aws-sdk-resources/lib/aws-sdk-resources/services/s3/presigned_post.rb @@ -444,7 +444,7 @@ def content_length_range(byte_range) # configuration. # @param [String] value Storage class to use for storing the # @return [self] - define_field(:storage_class) + define_field(:storage_class, 'x-amz-storage-class') # @!method website_redirect_location(value) # If the bucket is configured as a website, diff --git a/aws-sdk-resources/spec/services/s3/presigned_post_spec.rb b/aws-sdk-resources/spec/services/s3/presigned_post_spec.rb index 97376777192..b6b8470ef21 100644 --- a/aws-sdk-resources/spec/services/s3/presigned_post_spec.rb +++ b/aws-sdk-resources/spec/services/s3/presigned_post_spec.rb @@ -258,7 +258,12 @@ def policy(post) expect(post.fields['x-amz-security-token']).to eq('token') expect(policy(post)).to include('x-amz-security-token' => 'token') end - + + it 'sets the storage class if requested' do + creds = Credentials.new('key', 'secret', 'token') + post = PresignedPost.new(creds, region, bucket).key('key').storage_class('REDUCED_REDUNDANCY') + expect(post.fields['x-amz-storage-class']).to eq('REDUCED_REDUNDANCY') + end end end end