Heroku, CarrierWave, MiniMagick: no random tmp file

in my RoR project I use CarrierWave + MiniMagick and hosted in Heroku for production.

I have this problem in production that sometimes the tmp file for image processing is missing. I get this error:

Errno::ENOENT: No such file or directory - /tmp/mini_magick20130319-2-3wq6l6.jpg

I have other XUploader classes that work, but this one has two image processes. Initially, I had two separate processes for this:

  process :resizer def resizer resize_to_fit(model.jrac_image_width, model.jrac_image_height) end process :cropper def cropper manipulate! do |img| img.crop("442x190+#{model.jrac_crop_x}+#{model.jrac_crop_y}") img end end 

but he said that I have an error on :cropper , saying that the tmp file does not exist. I tried changing the code to this, I hope that it will work only once:

  process :resize_and_crop def resize_and_crop manipulate! do |img| img.resize("#{model.jrac_image_width}x#{model.jrac_image_height}") # resize_to_fit img.crop("442x190+#{model.jrac_crop_x}+#{model.jrac_crop_y}") # cropper img end end 

but unfortunately they still experience the same errors.

Does anyone know where the problem is? I do not know if it was with Heroku or CarrierWave or ImageMagick?

Edit

I also have this code in the Uploader class

  def cache_dir "#{Rails.root}/tmp/uploads" end 

as for this.

+6
source share
1 answer

heroku will occasionally empty tmp, usually we use s3 or other cloud storage to store the processed version. You can refer to https://github.com/jnicklas/carrierwave and https://github.com/jnicklas/carrierwave/wiki/How-to%3A-Make-Carrierwave-work-on-Heroku

They have a detailed step-by-step guide on using the carrier wave in heroics. I tried this before, and it works.

0
source

Source: https://habr.com/ru/post/943851/


All Articles