Skip to content

Commit

Permalink
Fix storage class setting on PresignedPost
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
julik committed Sep 13, 2015
1 parent 91591a4 commit 401acb2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
7 changes: 6 additions & 1 deletion aws-sdk-resources/spec/services/s3/presigned_post_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 401acb2

Please sign in to comment.