urlからs3に画像をアップする
該当のファイルのcontent typeを知る
res = Net::HTTP.start(uri.host, uri.port) do |http|
http.get(uri.path, {'User-Agent' => UrlConcern::USER_AGENT})
end
res.content_type
高さと幅を知る
res = Net::HTTP.start(uri.host, uri.port) do |http|
http.get(uri.path, {'User-Agent' => UrlConcern::USER_AGENT})
end
magick = Magick::Image.from_blob(res.body).shift
width = magick.columns
height = magick.rows
s3にアップする
option = {
'Content-Type' => res.content_type,
'Content-Length' => res.body.length,
'x-amz-acl' => 'public-read',
'Cache-Control' => "max-age=#{24*60*60*7}, private, must-revalidate",
}
s3_storage.put_object(s3_bucket, path, body, option)