class CarrierWave::Storage::Dropbox

Public Instance Methods

dropbox_client() click to toggle source
# File lib/carrierwave/storage/dropbox.rb, line 25
def dropbox_client
  @dropbox_client ||= begin
    ::Dropbox::Client.new(config[:access_token])
  end
end
retrieve!(file_id) click to toggle source

Retrieve a single file

# File lib/carrierwave/storage/dropbox.rb, line 19
def retrieve!(file_id)
  # allow for use of either path or ID as the file identifier
  id = file_id.match(/^id:/) ? file_id : "/#{uploader.store_path file_id}"
  CarrierWave::Storage::Dropbox::File.new(uploader, config, id, dropbox_client)
end
store!(file) click to toggle source

Store a single file

# File lib/carrierwave/storage/dropbox.rb, line 12
def store!(file)
  location = "/#{uploader.store_path}"
  res = dropbox_client.upload(location, file.to_file)
  uploader.model.update_column uploader.mounted_as, res.id
end

Private Instance Methods

config() click to toggle source
# File lib/carrierwave/storage/dropbox.rb, line 33
def config
  @config ||= {}

  @config[:access_token] ||= uploader.dropbox_access_token

  @config
end