Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Carrierwave check if remote file exists via fog

I know I'm missing something really easy here...

CarrierWave::Storage::Fog::File has a method exists?

How do I use it? I'm just trying to check whether a previously uploaded file exists on the remote storage.

Neither my image object, nor my uploader object have access to this method. Surely I don't have to create a new CarrierWave::Storage::Fog::File object to test if the file exists?

If so, what parameters should I put in? It takes the following: uploader, base, path (I used the uploader, store directory and image url, but that didn't work)

like image 630
Demelziraptor Avatar asked Jul 07 '12 20:07

Demelziraptor


1 Answers

Suppose you have model User with a field image that you use Carrierwave on. You could now write:

user = User.first
user.image.file.exists?

This would execute a remote check that returns true or false

like image 56
Wouter Vegter Avatar answered Oct 29 '22 21:10

Wouter Vegter