0
0

More than 5 years have passed since last update.

RailsでAWS S3を使って画像アップでの解決策

Last updated at Posted at 2019-03-04

エラーコード

is not a recognized provider carrierwave

結果から言いますと下記のコードです。

config.fog_credentials = {
provider: 'AWS',
aws_access_key_id: 'アクセスキー',
aws_secret_access_key: 'シークレットアクセスキー',
region: 'ap-northeast-1',
path_style: true
}
config.asset_host = 'https://s3-ap-northeast-1.amazonaws.com/バケット名'

ポイント

今回アクセスキーとシークレットアクセスキーは直打ちでしております。

修正して治った点はregionの設定です。
AWS S3の設定では東京で設定をしていて
URLは「us-east-1」と表示されてましたが
「ap-northeast-1」と入力したら画像はS3にアップされました。

次は画像がうまく表示されませんでした。

解決策

,
config.asset_hostのURLを「
にしました。

これで無事
画像がAWS S3にアップされてアプリ内でアップした画像を表示できました。

0
0
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
0
0