Class: BrickFTP::RESTfulAPI::CompleteUpload

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

Overview

Completing an upload

Params

PARAMETER TYPE DESCRIPTION
ref string Unique identifier to reference this file upload. This identifier is needed for subsequent requests to the REST API to complete the upload or request more upload URLs.

Defined Under Namespace

Classes: Params

Instance Method Summary collapse

Methods included from Command

included, #initialize

Instance Method Details

#call(path, params) ⇒ BrickFTP::Types::File

After uploading the file to the file storage environment, the REST API needs to be notified that the upload was completed.

This is done by sending another POST request to /files/PATH_AND_FILENAME.EXT with parameter action set to end and parameter ref set to the reference ID returned at the start of the upload.

Parameters:

Returns:

Raises:

  • (BrickFTP::RESTfulAPI::Error)

    exception



39
40
41
42
43
# File 'lib/brick_ftp/restful_api/complete_upload.rb', line 39

def call(path, params)
  res = client.post("/api/rest/v1/files/#{ERB::Util.url_encode(path)}", params.to_h.compact.merge(action: 'end'))

  BrickFTP::Types::File.new(**res.symbolize_keys)
end