Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support to S3's GET link with response-* params #47

Closed
wants to merge 4 commits into
base: master
from

Conversation

Projects
None yet
2 participants
@chitsaou
Copy link

chitsaou commented Jan 31, 2011

Hi all,

I have added the response-* parameters support of S3 GET link. But as you can see my coding style is not pretty, neither did I run the unit test. But it works fine my project which needs this new feature provided by AWS, though. I hope that someone could improve these dirty codes. I did only tested the functionalities of response-cache-control and response-content-disposition; other parameters may or may not work.

In addition, some methods in lib/awsbase/support.rb were removed, and I just can't get the S3Interface work, so I added them back from 85cb08e.

Thanks.

Yu-Cheng Chuang

Reference: http://docs.amazonwebservices.com/AmazonS3/latest/API/RESTObjectGET.html

@chitsaou

This comment has been minimized.

Copy link
Author

chitsaou commented Jan 31, 2011

Note: there is a bug when setting "response-content-disposition" => "attachment; filename=blahblah" with blahblah containing non-ascii characters (e.g. Chinese characters or Japanese Kana)

@chitsaou

This comment has been minimized.

Copy link
Author

chitsaou commented Feb 1, 2011

Sorry, I forgot the sample code.

As you can see, there is one additional parameter in get_link , so if you wanna generate a get_link with response-* parameters, you also need to specify expire and headers.

For example, assume that s3instance is an instance of RightAws::S3Interface :

# Traditional way, without headers and response-* params
s3instance.get_link('bucket_name', 'key/song.mp3', 86400)
#=> https://bucket_name.s3.amazonaws.com:443/key%2Fsong.mp3?Signature=vIh5...&Expires=1296611902&AWSAccessKeyId=AK...

# To generate url with response-* params, headers parameter must be specified,
# and response-* params are in hash style
s3instance.get_link('bucket_name', 'key/song.mp3', 86400, 
  {}, # empty additional headers
  {
    "response-content-disposition" => "attachment; filename=good_song.mp3", # specify Content-disposition and filename
    "response-cache-control"=>"No-cache" # specify Cache-control
  }
)
#=> https://bucket_name.s3.amazonaws.com:443/key%2Fsong.mp3?response-cache-control=No-cache&response-content-disposition=attachment; filename=good_song.mp3&Signature=7TLD...&Expires=1296611902&AWSAccessKeyId=AK...
@chitsaou

This comment has been minimized.

Copy link
Author

chitsaou commented Feb 1, 2011

Hi all,

I have another commit which resolves the non-ascii filename issue, along with documents on how to generate GetObject link with response-* parameters.

Hope that it's helpful for you.

Yu-Cheng Chuang

@rbroemeling

This comment has been minimized.

Copy link
Contributor

rbroemeling commented Mar 29, 2011

Hi chitsaou,

Thanks for doing the work on this! I've rewritten your patches quite thoroughly, cleaning them up as you asked. The cleaned up version is available here: #63

Thanks,

Remi

@chitsaou

This comment has been minimized.

Copy link
Author

chitsaou commented Apr 21, 2011

Hi Remi:

Thanks, your implementation is better than mine. I'll close my request :)

Yu-Cheng

@chitsaou chitsaou closed this Apr 21, 2011

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.