10
8

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.

[Rails→fog→CarrierWave→AWS S3] bundle installでコケた話

Last updated at Posted at 2018-06-04

経緯

fogを使ってawsに画像をUploadしようとしたらコケた。
調べたらCarrierWaveの公式に書かれていたが、覚書としてまとめておく。
https://github.com/carrierwaveuploader/carrierwave#using-amazon-s3

TL;DR

Ralisでfog、CarrierWave経由でAWS-S3に画像をアップロードさせる場合は、fogではなくfog-awsを使う。
これに伴い設定に一行追加する。

詳細

gemfile
gem 'fog-aws'
# gem 'fog'はいらない
Carrierwave.rb
CarrierWave.configure do |config|
  config.storage :fog
  config.fog_provider = 'fog/aws' # 追加
  config.fog_credentials = {
    provider: 'AWS',
    aws_access_key_id: Rails.application.secrets.aws_access_key_id,
    aws_secret_access_key: Rails.application.secrets.aws_secret_access_key,
    region: '任意の値'
  }

  config.fog_directory  = '任意の値'
  config.asset_host = '任意の値'
  end

end
10
8
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
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?