2
2

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.

paperclipでS3にアップするとき「AWS::S3::Errors::PermanentRedirect」なんて怒られたら

Posted at

そもそものはじまり

paperclip、便利ですよね。
s3と組み合わせるとクラウド上におけたりしてもっと便利です。

でも設定間違えるとなかなかアップできなくてもどかしい思いをしたりします。今回は以下のエラーでつまづいたので対処法を。

AWS::S3::Errors::PermanentRedirect (The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint.):」

要するにendpointのURL間違っているよーってことです。

paperclipのちょっと前のバージョンでは「s3.amazon.com」直書きだったようですが、新しいものからは以下の設定が必要になります。

s3にアップする設定を用意する

そこにはこんな感じで書きます。

  has_attached_file :file, 
                    :storage => :s3,
                    :s3_credentials => {
                      :access_key_id => S3KEY,
                      :secret_access_key => S3SECRET,
                      :s3_host_name =>  "s3-ap-northeast-1.amazonaws.com"
                    }

:s3_host_nameが必要です。
これをわすれるとs3.amazon.comが指定され、タイトルのようなエラーが発生してしまいます。

あとはいつもどおりフォームをつくってアップしてみてください。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?