Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In CarrierWave, what does retrieve_from_store! do?

The documentation says about retrieve_from_store!:

Retrieves the file from the storage.

But when I call the method, rather than getting something like a file, I just get an array returned:

irb(main):008:0> uploader.retrieve_from_store!('my_file.png')
=> [:retrieve_versions_from_store!]

What exactly does the method do?

like image 359
Andrew Grimm Avatar asked Jun 16 '16 00:06

Andrew Grimm


2 Answers

I was looking for the same thing today. Found something from Jonas Nicklas in the CarrierWave forum here...

retrieve_from_store! changes the state of the uploader, it doesn't return anything sensible. You want to do this:

uploader.retrieve_from_store!('test.jpg')
uploader.do_whatever

The return value from retrieve_from_store! is irrelevant.

like image 63
djb Avatar answered Nov 03 '22 20:11

djb


I just needed to use model.uploader.read to get to the bytes. It seems, uploader delegates to the file via Proxy: https://github.com/carrierwaveuploader/carrierwave/blob/master/lib/carrierwave/uploader/proxy.rb#L43

like image 40
Jasper Avatar answered Nov 03 '22 22:11

Jasper