Class: S3::ObjectPutRequest
- Defined in:
- lib/s3/object_put_request.rb
Constant Summary
Constants inherited from Request
Request::AWS_ALGORITHM, Request::AWS_REQUEST, Request::SERVICE, Request::UNSIGNED_PAYLOAD
Instance Method Summary collapse
Methods inherited from Request
Constructor Details
This class inherits a constructor from S3::Request
Instance Method Details
#parse_response(response) ⇒ Object
29 30 31 32 33 34 |
# File 'lib/s3/object_put_request.rb', line 29 def parse_response( response ) { etag: response.headers[ 'etag' ]&.tr( '"', '' ), version_id: response.headers[ 'x-amz-version-id' ] } end |
#submit(options = nil, bucket:, key:, body:, **kwargs) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/s3/object_put_request.rb', line 3 def submit( = nil, bucket:, key:, body:, **kwargs ) path = "/#{ bucket }/#{ Helpers.encode_key( key ) }" = ( , kwargs, ObjectPutOptions ) headers = {} headers[ 'Content-Type' ] = [ :content_type ] if [ :content_type ] headers[ 'x-amz-acl' ] = [ :acl ] if [ :acl ] headers[ 'x-amz-storage-class' ] = [ :storage_class ] if [ :storage_class ] headers[ 'Cache-Control' ] = [ :cache_control ] if [ :cache_control ] headers[ 'Content-Disposition' ] = [ :content_disposition ] if [ :content_disposition ] headers[ 'Content-Encoding' ] = [ :content_encoding ] if [ :content_encoding ] headers[ 'Content-Language' ] = [ :content_language ] if [ :content_language ] headers[ 'Expires' ] = [ :expires ].httpdate if [ :expires ] [ :metadata ]&.each do | , value | headers[ "x-amz-meta-#{ }" ] = value.to_s end response = put( path, body: body, headers: headers ) build_result( response, ObjectPutResult ) do ObjectPutResult.new( parse_response( response ) ) end end |