LoginSignup
1

More than 5 years have passed since last update.

Faraday で s3 の公開領域にバイナリを PUT する

Posted at

よくよく考えたら当然のことだが、multipart では PUT できない。

Faraday.new(url: s3_url).put do |req|
  req.header['Content-Type'] = 'application/octet-stream'
  req.body = File.binread('/path/to/file')
end

Content-Type は PUT するバイナリの Content Type に合わせる。

セキュアな bucket に PUT したい場合、Authorization ヘッダがさらに必要になる。

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
1