Module: Fog::AWS::Storage::PostObjectHiddenFields
Instance Method Summary collapse
-
#post_object_hidden_fields(options = {}) ⇒ Object
Get a hash of hidden fields for form uploading to S3, in the form => :field_value Form should look like: <form action=“http://#bucket_name.s3.amazonaws.com/” method=“post” enctype=“multipart/form-data”> These hidden fields should then appear, followed by a field named ‘file’ which is either a textarea or file input.
Instance Method Details
#post_object_hidden_fields(options = {}) ⇒ Object
Get a hash of hidden fields for form uploading to S3, in the form => :field_value Form should look like: <form action=“http://#bucket_name.s3.amazonaws.com/” method=“post” enctype=“multipart/form-data”> These hidden fields should then appear, followed by a field named ‘file’ which is either a textarea or file input.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/fog/aws/requests/storage/post_object_hidden_fields.rb', line 25 def post_object_hidden_fields( = {}) = .dup if policy = ['policy'] date = Fog::Time.now credential = "#{@aws_access_key_id}/#{@signer.credential_scope(date)}" extra_conditions = [ {'x-amz-date' => date.to_iso8601_basic}, {'x-amz-credential' => credential}, {'x-amz-algorithm' => Fog::AWS::SignatureV4::ALGORITHM} ] extra_conditions << {'x-amz-security-token' => @aws_session_token } if @aws_session_token policy_with_auth_fields = policy.merge('conditions' => policy['conditions'] + extra_conditions) ['policy'] = Base64.encode64(Fog::JSON.encode(policy_with_auth_fields)).gsub("\n", "") ['X-Amz-Credential'] = credential ['X-Amz-Date'] = date.to_iso8601_basic ['X-Amz-Algorithm'] = Fog::AWS::SignatureV4::ALGORITHM if @aws_session_token ['X-Amz-Security-Token'] = @aws_session_token end ['X-Amz-Signature'] = @signer.derived_hmac(date).sign(['policy']).unpack('H*').first end end |