CarrierWave Backgrounder process leaves denied access to s3 image

旧时模样 提交于 2020-02-08 09:15:09

问题


My current Sidekiq setup with the following is processing the image, but nothing is being done in the background. The page takes 10 seconds to load and then the new image is shown on the redirected page with the following path. https://d9vwx0ll7rhpx.cloudfront.net/development/photo/image/product_thumb/product_thumb_0046d4ca-ca8d-4c02-b8cd-da0255c5736e.jpg

I would like for this process to be done in the background.

def create
@photo = Photo.new(photo_params)
if @photo.save
  UploadsWorker.perform_async(@photo.id, photo_params)
  flash[:notice] = "Your new photograph is being processed."
  redirect_to photographer_listings_path(@photog)
else
  flash[:notice] =  "Check the fields marked with an orange flag."
  render 'new'
end

end

class UploadsWorker
 include Sidekiq::Worker

 def perform(photo_id, photo_params)
  photo = Photo.find(photo_id)
  photo.image = photo_params["image"]
  photo.save
end

end

I instead tried to use the CarrierWave Backgrounder gem, but found that the version processing doesnt take place. The code runs but I am left with no image on the page redirect after a new record saves.

When looking at the Sidekiq web interface, I can see that the job is being run and then completes.

However I am left with an image ( within the same directory) that has denied access.

Strange that occurs seeing the url shown at the top when not using the gem was valid.

https://d9vwx0ll7rhpx.cloudfront.net/development/photo/image/product_thumb/product_thumb_a9cf111f-c93a-4ec3-b1be-293321147000.jpg


回答1:


I had to use store_in_background rather than process_in_background in order for the image to be properly uploaded to s3



来源:https://stackoverflow.com/questions/29134806/carrierwave-backgrounder-process-leaves-denied-access-to-s3-image

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!