Uploads silently failing/pausing with new carrierw

2019-09-06 19:51发布

i am having a small problem uploading files to s3 with new carrierwave_direct gem

I have followed the instructions for installing and setting up carrierwave_direct, however when i try to upload to s3, the upload begins and then pauses the upload at some point. Any thoughts?

Also sometimes i get this message from s3:

<Error>
    <Code>InvalidPolicyDocument</Code>
    <Message>
        Invalid Policy: Invalid 'expiration' value: '2011-09-13T07:52:58+02:00'
    </Message>
    <RequestId>"some id"</RequestId>
    <HostId>
        "some host id"
    </HostId>
</Error>

I have created an initializes file called carrierwave.rb with all my credentials from amazon s3. I have also loaded all the required gems(carrierwave_direct, fog, carrierwave)

Checkout my code here on gist

Has anybody else been able to get this working

Thank for for the help

2条回答
看我几分像从前
2楼-- · 2019-09-06 20:19

I would try removing this line from your carrierwave_fog.rb config:

config.fog_attributes = {'Cache-Control'=>'max-age=315576000'}  # optional, defaults to {}

It sounds like your document expiration date is invalid because it is too close to the current date/time.

Also, you may need to uncomment your #storage :fog line in your ImageUploader. See if that helps.

查看更多
姐就是有狂的资本
3楼-- · 2019-09-06 20:23

The author of this gem had found that the problem was with rails 3.0.x versions, to make this gem work you need to add the following line to config/application.rb:

config.action_controller.allow_forgery_protection = false

and remove the following from my carrierwave.rb file in config/initilizers:

config.fog_host       = 'https://#{fog_directory}.s3.amazonaws.com'

as this will automatically be determined by the fog directory.

The author mentioned as well that if you are using rails 3.1.x you do not need to perform the above mentioned steps. Hope this helps

查看更多
登录 后发表回答