Class: CarrierWave::Storage::Dropbox::File

Inherits:
Object
  • Object
show all
Includes:
Utilities::Uri
Defined in:
lib/carrierwave/storage/dropbox.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uploader, config, path, client) ⇒ File

Returns a new instance of File.



51
52
53
# File 'lib/carrierwave/storage/dropbox.rb', line 51

def initialize(uploader, config, path, client)
  @uploader, @config, @path, @client = uploader, config, path, client
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



49
50
51
# File 'lib/carrierwave/storage/dropbox.rb', line 49

def path
  @path
end

Instance Method Details

#deleteObject



64
65
66
67
68
69
70
# File 'lib/carrierwave/storage/dropbox.rb', line 64

def delete
  path = "/Public/#{@path}" if @config[:access_type] == "dropbox"
  begin
    @client.file_delete(path)
  rescue DropboxError
  end
end

#urlObject



55
56
57
58
59
60
61
62
# File 'lib/carrierwave/storage/dropbox.rb', line 55

def url
  user_id, path = @config[:user_id], @path
  if @config[:access_type] == "dropbox"
    "https://dl.dropboxusercontent.com/u/#{user_id}/#{path}"
  else
    @client.media(path)["url"]
  end
end