10
11

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Fog で S3 の期限付きダウンロード URL を作りたい

Posted at

Fog で S3 の期限付き URL を取得したい場合は、Fog::Storage::AWS::File#url を使用すればよい。有効期限となる時刻は引数で指定する。

require 'active_support/core_ext'
require 'fog'

fog_storage = Fog::Storage.new(aws_settings)
bucket = fog_storage.directories.get(bucket_name)
file = bucket.get(path)

expire_time = 30.second.since

file.url(expire_time)
10
11
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
10
11

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?