LoginSignup
5
5

More than 5 years have passed since last update.

aws-s3を使ってS3上のファイルの期限付きURLを発行する方法

Posted at

AWSのS3の機能として一定期間のみ有効なURLを発行することが出来る。これをaws-s3(http://amazon.rubyforge.org/) を利用して発行する方法

ex) mybuckets/example.txtに対する30秒で失効するURLを発行
require 'rubygems'
require 'aws/s3'

include AWS::S3

BUCKET_NAME = 'mybuckets'

Base.establish_connection!(
  :access_key_id => "Input Your Access Key",
  :secret_access_key => "Input Your Secret Access Key"
)

example = S3Object.find 'example.txt', BUCKET_NAME
url = example.url(:expires_in => 30)
5
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
5