内容
S3を導入したのですが、画像を投稿した際に「 Excon::Error::Forbidden (Expected(200) <=> Actual(403 Forbidden)」という内容のエラーが出てしまいます。
アクセスキー、シークレットキーが異なる場合に出てしまうようなのですが、アクセスキー、シークレットキーは新たに作成してコピペしたものでした。
内容が間違っているように思えず、他の原因が考えられたら教えていただきたいです。
●試したこと
config/initializers/carrierwave.rbのアクセスキー、シークレットキーの内容が間違っている可能性を考え見返しましましたが、正しく記入できていました。
エラー内容(production.log)
F, [2020-10-25T12:09:31.088895 #3521] FATAL -- : [0b727f68-4bce-440a-be3f-f3139423e7c0] F, [2020-10-25T12:09:31.088947 #3521] FATAL -- : [0b727f68-4bce-440a-be3f-f3139423e7c0] Excon::Error::Forbidden (Expected(200) <=> Actual(403 Forbidden) excon.error.response :body => "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Error><Code>SignatureDoesNotMatch</Code><Message>The request signature we calculated does not match the signature you provided. Check your key and signing method.</Message><AWSAccessKeyId>AKIAQFS7WHTZ6FWVOKW6</AWSAccessKeyId><StringToSign>AWS4-HMAC-SHA256\n20201025T120930Z\n20201025/ap-northeast-1/s3/aws4_request\ndc57eea501cca32ad728faa006fb00fffce00232b95a8f7df37f7a4362adce0d</StringToSign><SignatureProvided>30c44aafd5769eab9ac69f25f5501e2e5abe4fd2dc013e226ef6c608e28eb2a6</SignatureProvided><StringToSignBytes>41 57 53 34 2d 48 4d 41 43 2d 53 48 41 32 35 36 0a 32 30 32 30 31 30 32 35 54 31 32 30 39 33 30 5a 0a 32 30 32 30 31 30 32 35 2f 61 70 2d 6e 6f 72 74 68 65 61 73 74 2d 31 2f 73 33 2f 61 77 73 34 5f 72 65 71 75 65 73 74 0a 64 63 35 37 65 65 61 35 30 31 63 63 61 33 32 61 64 37 32 38 66 61 61 30 30 36 66 62 30 30 66 66 66 63 65 30 30 32 33 32 62 39 35 61 38 66 37 64 66 33 37 66 37 61 34 33 36 32 61 64 63 65 30 64</StringToSignBytes><CanonicalRequest>PUT\n/uploads/micropost/image/6/gek3qfu5hwojipcw2cec.jpg\n\ncontent-type:image/jpeg\nhost:bucketrugby.s3.ap-northeast-1.amazonaws.com\nx-amz-acl:private\nx-amz-content-sha256:STREAMING-AWS4-HMAC-SHA256-PAYLOAD\nx-amz-date:20201025T120930Z\nx-amz-decoded-content-length:268912\n\ncontent-type;host;x-amz-acl;x-amz-content-sha256;x-amz-date;x-amz-decoded-content-length\nSTREAMING-AWS4-HMAC-SHA256-PAYLOAD</CanonicalRequest><CanonicalRequestBytes>50 55 54 0a 2f 75 70 6c 6f 61 64 73 2f 6d 69 63 72 6f 70 6f 73 74 2f 69 6d 61 67 65 2f 36 2f 67 65 6b 33 71 66 75 35 68 77 6f 6a 69 70 63 77 32 63 65 63 2e 6a 70 67 0a 0a 63 6f 6e 74 65 6e 74 2d 74 79 70 65 3a 69 6d 61 67 65 2f 6a 70 65 67 0a 68 6f 73 74 3a 62 75 63 6b 65 74 72 75 67 62 79 2e 73 33 2e 61 70 2d 6e 6f 72 74 68 65 61 73 74 2d 31 2e 61 6d 61 7a 6f 6e 61 77 73 2e 63 6f 6d 0a 78 2d 61 6d 7a 2d 61 63 6c 3a 70 72 69 76 61 74 65 0a 78 2d 61 6d 7a 2d 63 6f 6e 74 65 6e 74 2d 73 68 61 32 35 36 3a 53 54 52 45 41 4d 49 4e 47 2d 41 57 53 34 2d 48 4d 41 43 2d 53 48 41 32 35 36 2d 50 41 59 4c 4f 41 44 0a 78 2d 61 6d 7a 2d 64 61 74 65 3a 32 30 32 30 31 30 32 35 54 31 32 30 39 33 30 5a 0a 78 2d 61 6d 7a 2d 64 65 63 6f 64 65 64 2d 63 6f 6e 74 65 6e 74 2d 6c 65 6e 67 74 68 3a 32 36 38 39 31 32 0a 0a 63 6f 6e 74 65 6e 74 2d 74 79 70 65 3b 68 6f 73 74 3b 78 2d 61 6d 7a 2d 61 63 6c 3b 78 2d 61 6d 7a 2d 63 6f 6e 74 65 6e 74 2d 73 68 61 32 35 36 3b 78 2d 61 6d 7a 2d 64 61 74 65 3b 78 2d 61 6d 7a 2d 64 65 63 6f 64 65 64 2d 63 6f 6e 74 65 6e 74 2d 6c 65 6e 67 74 68 0a 53 54 52 45 41 4d 49 4e 47 2d 41 57 53 34 2d 48 4d 41 43 2d 53 48 41 32 35 36 2d 50 41 59 4c 4f 41 44</CanonicalRequestBytes><RequestId>3112DE8BE1E3FDFB</RequestId><HostId>wwrbcevJDZehoQS7AAtUcvF55SmkCZsGfH1fi3z2olQLETa/zivHyByMrKaPdqiuFgA3dsK1IC8=</HostId></Error>" :cookies => [ ] :headers => { "Connection" => "close" "Content-Type" => "application/xml" "Date" => "Sun, 25 Oct 2020 12:09:30 GMT" "Server" => "AmazonS3" "x-amz-id-2" => "wwrbcevJDZehoQS7AAtUcvF55SmkCZsGfH1fi3z2olQLETa/zivHyByMrKaPdqiuFgA3dsK1IC8=" "x-amz-request-id" => "3112DE8BE1E3FDFB" } :host => "bucketrugby.s3.ap-northeast-1.amazonaws.com" :local_address => "10.0.0.218" :local_port => 60666 :path => "/uploads/micropost/image/6/gek3qfu5hwojipcw2cec.jpg" :port => 443 :reason_phrase => "Forbidden" :remote_ip => "52.219.4.171" :status => 403 :status_line => "HTTP/1.1 403 Forbidden\r\n" ): F, [2020-10-25T12:09:31.088981 #3521] FATAL -- : [0b727f68-4bce-440a-be3f-f3139423e7c0] F, [2020-10-25T12:09:31.089006 #3521] FATAL -- : [0b727f68-4bce-440a-be3f-f3139423e7c0] app/controllers/microposts_controller.rb:38:in `create'
あなたの回答
tips
プレビュー