Class: DropboxApi::Endpoints::Files::Upload

Inherits:
ContentUpload show all
Defined in:
lib/dropbox_api/endpoints/files/upload.rb

Constant Summary collapse

Method =
:post
Path =
"/2/files/upload".freeze
ResultType =
DropboxApi::::File
ErrorType =
DropboxApi::Errors::UploadError

Instance Method Summary collapse

Methods inherited from ContentUpload

#build_request, #initialize, #perform_request

Methods inherited from Base

add_endpoint

Constructor Details

This class inherits a constructor from DropboxApi::Endpoints::ContentUpload

Instance Method Details

#upload(path, content, options = {}) ⇒ Object

Creates a new file.

Do not use this to upload a file larger than 150 MB. Instead, create an upload session with #upload_session_start().

Examples:

client = DropboxApi::Client.new
file_content = IO.read "local_image.png"
client.upload "/image.png", file_content
#=> #<DropboxApi::Metadata::File: @name="image.png" ...>
client = DropboxApi::Client.new
client.upload "/file.txt", "Contents of a plain text file."
#=> #<DropboxApi::Metadata::File: @name="file.txt" ...>

Parameters:

  • path (String)

    Path in the user’s Dropbox to save the file.

  • content

    The contents of the file that will be uploaded. This could be the result of the IO::read method.

Options Hash (options):

  • autorename (Boolean)

    If there’s a conflict, as determined by mode, have the Dropbox server try to autorename the file to avoid conflict. The default for this field is False.

  • mute (Boolean)

    Normally, users are made aware of any file modifications in their Dropbox account via notifications in the client software. If true, this tells the clients that this modification shouldn’t result in a user notification. The default for this field is false.



34
35
36
# File 'lib/dropbox_api/endpoints/files/upload.rb', line 34

add_endpoint :upload do |path, content, options = {}|
  perform_request({:path => path}, content)
end