Class: CarrierWave::Storage::Dropbox

Inherits:
Abstract
  • Object
show all
Defined in:
lib/carrierwave/storage/dropbox.rb

Defined Under Namespace

Classes: File

Instance Method Summary collapse

Instance Method Details

#dropbox_clientObject



22
23
24
25
26
27
28
# File 'lib/carrierwave/storage/dropbox.rb', line 22

def dropbox_client
  @dropbox_client ||= begin
    session = DropboxSession.new(config[:app_key], config[:app_secret])
    session.set_access_token(config[:access_token], config[:access_token_secret])
    DropboxClient.new(session, config[:access_type])
  end
end

#retrieve!(file) ⇒ Object

Retrieve a single file



18
19
20
# File 'lib/carrierwave/storage/dropbox.rb', line 18

def retrieve!(file)
  CarrierWave::Storage::Dropbox::File.new(uploader, config, uploader.store_path(file), dropbox_client)
end

#store!(file) ⇒ Object

Store a single file



12
13
14
15
# File 'lib/carrierwave/storage/dropbox.rb', line 12

def store!(file)
  location = (config[:access_type] == "dropbox") ? "/#{uploader.store_path}" : uploader.store_path
  dropbox_client.put_file(location, file.to_file)
end