Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uploader recreate_versions! doesn't work #37

Open
Owumaro opened this issue Oct 13, 2017 · 1 comment
Open

Uploader recreate_versions! doesn't work #37

Owumaro opened this issue Oct 13, 2017 · 1 comment

Comments

@Owumaro
Copy link

Owumaro commented Oct 13, 2017

Hi

I'm using carrierwave-ftp 0.3.1 (with carrierwave 1.2.1) to manage some image uploads with versions. I changed the processing of a version and need to reprocess all the existing images. So I'm trying to use recreate_versions! on the uploader:
https://github.com/carrierwaveuploader/carrierwave#recreating-versions

It throws a NameError:

> model.img.recreate_versions!
NameError: undefined local variable or method `file' for #<CarrierWave::Storage::FTP::File:0x00000006345c50>
	from /.../gems/carrierwave-ftp-0.3.1/lib/carrierwave/storage/ftp.rb:76:in `content_type'
	from /.../gems/carrierwave-1.2.1/lib/carrierwave/uploader/cache.rb:86:in `sanitized_file'
	from /.../gems/carrierwave-1.2.1/lib/carrierwave/uploader/cache.rb:118:in `cache!'
	from /.../gems/carrierwave-1.2.1/lib/carrierwave/uploader/versions.rb:227:in `recreate_versions!'

I found this wiki entry: https://github.com/carrierwaveuploader/carrierwave/wiki/How-to:-Recreate-and-reprocess-your-files-stored-on-fog
Which explains that the base img must be cached to reprocess it. It seems like the carrierwave-ftp File class doesn't implement the required methods.

Calling cache_stored_file! on the uploader produces the same error as above.

Thanks !

@Owumaro
Copy link
Author

Owumaro commented Oct 13, 2017

After investigation, I managed to make it work by manually setting a content_type on the file of the uploader:

> model.img.file.content_type = ""
=> ""
> model.img.recreate_versions!
=> [:store_versions!]

Edit: this only works if the image is still in the carrierwave cache. Otherwise you get a CarrierWave::ProcessingError: identify /tmp/mini_magick20171016-15060-1icpymt.png failed with error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant