fog / fog-aws

Module for the 'fog' gem to support Amazon Web Services http://aws.amazon.com/
MIT License
300 stars 352 forks source link

Fog::AWS::Storage::File - fix request id header reflection #689

Closed rahim closed 1 year ago

rahim commented 1 year ago

Resolves #688


This fixed behaviour in the following scenario:

s3 = Fog::Storage.new(config)
bucket = s3.directories.new(key: 'rahim-throwaway-us-east-1')
file = bucket.files.create(key: 'foo', body: 'bar')
file = bucket.files.get('foo')
# =>   <Fog::AWS::Storage::File
#     key="foo",
#     cache_control=nil,
#     content_disposition=nil,
#     content_encoding=nil,
#     content_length=3,
#     content_md5=nil,
#     content_type="",
#     etag="37b51d194a7513e45b56f6524f2d51f2",
#     expires=nil,
#     last_modified=2023-09-19 15:18:30 +0000,
#     metadata={"x-amz-id-2"=>"P6b145GU6tllNufELCAYtGGNIvqijkuVoayaabSTGi3d4dVxzZCM5TYiaCgZhvOpmJO/SKTHyOnpQw65oXKXug==", "x-amz-request-id"=>"PAYX90KF2VFZMBVH"},
#     owner=nil,
#     storage_class=nil,
#     encryption="AES256",
#     encryption_key=nil,
#     version=nil,
#     kms_key_id=nil,
#     tags=nil,
#     website_redirect_location=nil
#   >
file.save
# The file instance above carries state from previous API requests.
# In particular fog carries forward x-amz-id-2 and x-amz-request-id from
# the last response and includes that in the next request
#
# Most of the time S3 just ignores this silently, but intermittently it
# becomes more fussy and rejects with Forbidden
geemus commented 1 year ago

@rahim do you need this in a release?

rahim commented 1 year ago

Thanks @geemus, a release would be much appreciated!

geemus commented 1 year ago

Should now be available in v3.20.0. Thanks!