简体   繁体   English

重新归档返回的Aws :: S3 :: Errors :: Forbidden:错误

[英]Refile returning Aws::S3::Errors::Forbidden: error

All of a sudden Refile gem has started throwing Aws::S3::Errors::Forbidden: error while trying to fetch images from S3 bucket. 突然,所有Refile gem都开始抛出Refile Aws::S3::Errors::Forbidden:尝试从S3存储桶中获取图像时出错。 Although I am able to upload/fetch new images, this issue occurs only for older files. 虽然我能够上载/获取新图像,但是仅旧文件才出现此问题。

I tried adding new bucket policy to S3 as mentioned here: https://github.com/aws/aws-sdk-ruby/issues/201 but none seemed to work for me, may be i didn't write it correct. 我尝试将新的存储桶策略添加到S3,如下所述: https : //github.com/aws/aws-sdk-ruby/issues/201,但似乎对我没有用,可能是我写的不正确。

{
"Version": "2012-10-17",
"Statement": [
    {
        "Effect": "Allow",
        "Principal": "*",
        "Action": "s3:*",
        "Resource": [
            "arn:aws:s3:::bucket/*",
            "arn:aws:s3:::bucket"
        ]
    }
]
}

below is the error log: 下面是错误日志:

Aws::S3::Errors::Forbidden:
from /home/deploy/hutfy/shared/bundle/ruby/2.3.0/gems/aws-sdk-resources-2.6.4/lib/aws-sdk-resources/resource.rb:134:in `rescue in exists?'
from /home/deploy/hutfy/shared/bundle/ruby/2.3.0/gems/aws-sdk-resources-2.6.4/lib/aws-sdk-resources/resource.rb:131:in `exists?'
from /home/deploy/hutfy/shared/bundle/ruby/2.3.0/gems/refile-s3-0.2.0/lib/refile/s3.rb:126:in `exists?'
from /home/deploy/hutfy/shared/bundle/ruby/2.3.0/bundler/gems/refile-d7a42dcd7cf6/lib/refile/backend_macros.rb:11:in `block (2 levels) in verify_id'
from /home/deploy/hutfy/shared/bundle/ruby/2.3.0/bundler/gems/refile-d7a42dcd7cf6/lib/refile/file.rb:53:in `exists?'
from (irb):3
from /home/deploy/hutfy/shared/bundle/ruby/2.3.0/gems/railties-4.2.6/lib/rails/commands/console.rb:110:in `start'
from /home/deploy/hutfy/shared/bundle/ruby/2.3.0/gems/railties-4.2.6/lib/rails/commands/console.rb:9:in `start'
from /home/deploy/hutfy/shared/bundle/ruby/2.3.0/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:68:in `console'
from /home/deploy/hutfy/shared/bundle/ruby/2.3.0/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from /home/deploy/hutfy/shared/bundle/ruby/2.3.0/gems/railties-4.2.6/lib/rails/commands.rb:17:in `<top (required)>'
from bin/rails:8:in `require'
from bin/rails:8:in `<main>'

It turns out the clock on server and S3 were out of sync. 事实证明服务器上的时钟和S3不同步。 running below command resolved the issue: 在以下命令中运行可解决问题:

sudo apt-get install ntp
service ntp stop
sudo ntpdate -s 0.amazon.pool.ntp.org
service ntp start

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM