Class: DropboxApi::Endpoints::Files::Move

Inherits:
Rpc
  • Object
show all
Includes:
OptionsValidator
Defined in:
lib/dropbox_api/endpoints/files/move.rb

Constant Summary collapse

Method =
:post
Path =
"/2/files/move".freeze
ResultType =
DropboxApi::Metadata::Resource
ErrorType =
DropboxApi::Errors::RelocationError

Instance Method Summary collapse

Methods included from OptionsValidator

#validate_options

Methods inherited from Rpc

#build_request, #initialize, #request_body

Methods inherited from Base

add_endpoint

Constructor Details

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

Instance Method Details

#move(from, to, options = {}) ⇒ Object

Move a file or folder to a different location in the user's Dropbox.

If the source path is a folder all its contents will be moved.

Parameters:

  • from (String)

    Path in the user's Dropbox to be copied or moved.

  • to (String)

    Path in the user's Dropbox that is the destination.

Options Hash (options):

  • autorename (Boolean)

    If there's a conflict, have the Dropbox server try to autorename the file to avoid the conflict. The default for this field is false.


19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/dropbox_api/endpoints/files/move.rb', line 19

add_endpoint :move do |from, to, options = {}|
  # We're not implementing support for the `allow_shared_folder` option
  # because according to Dropbox's documentation: "This field is always
  # true for move".
  validate_options([
    :autorename
  ], options)

  perform_request options.merge({
    :from_path => from,
    :to_path => to
  })
end