Search code examples
ruby-on-railsamazon-web-servicesamazon-s3ruby-on-rails-5carrierwave

Issue in aws s3 bucket with x-amz-server-side-encryption policy not allowing rails5 to upload images but allows in rails4


We work on rails upgrade from rails 4.1 to 5.2. We face an issue in aws s3 bucket with x-amz-server-side-encryption policy not allowing rails5 to upload images but allows in rails4

s3 bucket has prevent-uploads-of-unencrypted-objects-to-amazon-s3 policy

Error:

Excon::Error::Forbidden (Expected(200) <=> Actual(403 Forbidden)

AccessDenied

rails4 gems

fog (1.28.0)

fog-aws (0.1.1)

rails5 gems

fog (2.2.0)

fog-aws (3.5.2)

Any suggestion ?? what i'am missing here??


Solution

  • Solution 1:

    With gem carrierwave-2.0.2 adding config.cache_storage = :file to config/initializers/s3.rb

    Solution 2:

    Fixed it by downgrade gem from carrierwave-2.0.2 to carrierwave-1.3.1

    note:

    a. storage with :fog and cache_storage is not configured(but default cache_storage :fog) does not work

    b. storage with :fog and cache_storage :file works