Class: BrickFTP::RESTfulAPI::DeleteFolder

Inherits:
Object
  • Object
show all
Includes:
Command
Defined in:
lib/brick_ftp/restful_api/delete_folder.rb

Overview

Delete a file or folder

Instance Method Summary collapse

Methods included from Command

included, #initialize

Instance Method Details

#call(path, recursive: false) ⇒ Object

Deletes a file or folder.

Note that this operation works for both files and folders, but normally it will only work on empty folders. If you want to recursively delete a folder and all its contents, send the request with a Depth header with the value set to infinity.

Parameters:

  • path (String)

    Full path of the file or folder. Maximum of 550 characters.

  • recursive (Boolean) (defaults to: false)


23
24
25
26
27
28
29
# File 'lib/brick_ftp/restful_api/delete_folder.rb', line 23

def call(path, recursive: false)
  headers = {}
  headers = { 'Depth' => 'infinity' } if recursive

  client.delete("/api/rest/v1/files/#{ERB::Util.url_encode(path)}", headers)
  true
end