Class: BrickFTP::RESTfulAPI::DownloadFile
- Inherits:
-
Object
- Object
- BrickFTP::RESTfulAPI::DownloadFile
- Includes:
- Command
- Defined in:
- lib/brick_ftp/restful_api/download_file.rb
Overview
Download a file
Params
PARAMETER | TYPE | DESCRIPTION |
---|---|---|
action | string | Optionally set to stat to have the download_uri field omitted in the response and no download action logged. |
Instance Method Summary collapse
-
#call(path, stat: false) ⇒ BrickFTP::Types::File
Provides a download URL that will enable you to download a file.
Methods included from Command
Instance Method Details
#call(path, stat: false) ⇒ BrickFTP::Types::File
Provides a download URL that will enable you to download a file.
The download URL is a direct URL to Amazon S3 that has been signed by BrickFTP to provide temporary access to the file. The download links are valid for 3 minutes.
By default this request assumes that the file will be downloaded, and therefore a download action is logged for the user that is logged into the REST API session. If downloading the file is not desired, but rather one is just looking at the information associated with the file such as the MD5 checksum or file size, then the action query parameter can be passed in on the URL with the value of stat. This causes the download_uri field to be omitted in the response and no download action to be logged.
35 36 37 38 39 40 41 42 |
# File 'lib/brick_ftp/restful_api/download_file.rb', line 35 def call(path, stat: false) endpoint = "/api/rest/v1/files/#{ERB::Util.url_encode(path)}" endpoint = "#{endpoint}?action=stat" if stat res = client.get(endpoint) return nil if !res || res.empty? BrickFTP::Types::File.new(**res.symbolize_keys) end |