Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
Help us understand the problem. What is going on with this article?

RMagickで画像を読み込む、サムネイル画像を生成しそのままS3に格納、時間制限URLを取得

More than 5 years have passed since last update.
thumbnail_on_s3.rb
require 'rmagick'
require 'aws/s3'

AWS::S3::Base.establish_connection!(:access_key_id=>'<YOUR_ID>', :secret_access_key=>'<YOUR_SECRET>')
AWS::S3::DEFAULT_HOST.replace 's3-ap-northeast-1.amazonaws.com' # if use Tokyo Region
img = Magick::ImageList.new('path/to/file.jpg')
AWS::S3::S3Object.store('filename_thumb_m.jpg', img.thumbnail(640,480).to_blob {self.quality=92}, '<bucket-name>')
AWS::S3::S3Object.store('filename_thumb_s.jpg', img.thumbnail(160,120).to_blob {self.quality=92}, '<bucket-name>')
# 1時間したらアクセス出来ないURLをゲット
puts AWS::S3::S3Object.url_for('filename_thumb_m.jpg', '<bucket-name>', :expires_in=>3600)
puts AWS::S3::S3Object.url_for('filename_thumb_s.jpg', '<bucket-name>', :expires_in=>3600)
iwazer
http://profile.livedoor.com/ratt777/
http://www.iwazer.com/~iwazawa/diary/
mapion
ワンマイル・イノベーション・カンパニー  普段の買い物、子育て、学校、休日のお出かけや趣味・・身の回り(=ワンマイル)でおきることに着目して、最もユーザーに身近なところからイノベーションを起こしていく。ユーザーの生活圏内(=ワンマイル)でイノベーションを起こし続ける企業を目指していきます。
https://onecompath.com
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away