Skip to content

Without Carrierwave

kenmazaika edited this page Apr 12, 2012 · 1 revision

This gem can be used without using carrierwave, for cases where the filedata needs to be processed, rather than stored using a carrierwave uploader.

To use this in stand-alone mode, go through the same steps as using carrierwave. Then you will also want to create a getter and setter for the field that will be cached.

The setter for the field that gets called will either get called with a Rack::Multipart::UploadedFile or a FileUploadCache::Tempfile. The tempfile will be a valid file during the call of the setter, and will also respond to original_filename with the filename that the initial uploaded file had. This tempfile however will not be able to be read outside the context of the setter (the tempfile will be closed after the setter is called). This means processing of the filedata needs to either happen in this location, or be stored in a format that will be accessible when the processing needs to happen.

Clone this wiki locally