Open Neil-Ni opened 8 years ago
Thanks for the report @Neil-Ni.
Any updates or workaround for this? @thomasfedb @Neil-Ni
@SergeyKishenin Did you ever get to a workaround?
There is a work around you could add this to your uploader :
def cache! file
save_original_filename file
super
end
@ajoanny Thanks a lot. It works!
There is a work around you could add this to your uploader :
def cache! file save_original_filename file super end
Is save_original_filename
deprecated? I'm getting a NoMethodError.
@blainelawson The method save_original_filename
doesn't exist in carrierwave. If you look carefully at the issue description above, it is a custom method used to get around the issue.
@sarojkh You are correct. My bad.
Hi guys,
Just came across an unexpected behavior in before :cache callback today, and would like to raise an issue. From official wiki, there's a snippet on how to save the original filename:
I was expecting the callback to return an original file, but after spending some time debugging I've found that
before :cache
callback doesn't actually execute before the cache. It actually allowsUploader::Cache.cache!
to be called with a new_file and then executing callbacks afterwards with an sanitized file.Not sure if this is by design but here are the related links to the code:
related code: https://github.com/carrierwaveuploader/carrierwave/blob/master/lib/carrierwave/uploader/cache.rb#L118 https://github.com/carrierwaveuploader/carrierwave/blob/master/lib/carrierwave/uploader/cache.rb#L137-L139 https://github.com/carrierwaveuploader/carrierwave/blob/master/lib/carrierwave/uploader/callbacks.rb#L13-L17
here's the spec I've written to clarify this error:
https://github.com/Neil-Ni/carrierwave/blob/f17ee898cf76866ada74fa0ee9f7170ce8f7c5d1/spec/uploader/callback_spec.rb#L29-L46
Rspec Error: