Method: CarrierWave::Storage::Fog::File#to_file

Defined in:
lib/carrierwave/storage/fog.rb

#to_fileObject

Return the local file

Returns

File

The local file as Ruby’s File class

or
NilClass

When there’s no file, or the file is remotely stored



470
471
472
473
474
475
476
477
478
# File 'lib/carrierwave/storage/fog.rb', line 470

def to_file
  return nil unless file.body.is_a? ::File

  if file.body.closed?
    ::File.open(file.body.path) # Reopen if it's already closed
  else
    file.body
  end
end