Download File

  • Is able to expose the (binary) content of a file.

  • Allows to save a file locally on disk.

  • Allows to show a file directly in the Browser.

  • Required security permission - READ.

  • HTTP methods supported: GET

Description

This endpoint allows to display the content of a file in a web browser or to download a file as an attachment locally on disk.

Parameters

Name Type Optional Description

pathspec

undefined

yes

The path or id of a File or FileList property containing the file to download.

filestore

undefined

yes

Specifies the path or the object ID the file store to be queried.

prev

undefined

yes

A filter can have an optional start value 'prev' which is typically the metatable obtained from a previous call to continue iterating over all matching entries. It may also be an integral row index (negative values are relative to the last row, i.e. specifying -2 returns the last table row if it matches). Must be a number or a Base64 encoded JSON dictionary.

filter

string

yes

A filter specification to lookup a file which is stored in a File or FileList property. Must be a string containing the name or a Base64 encoded JSON dictionary. See the getfilemetadata Lua function for details.

_id

string

yes

The MongoDB ObjectId of the file to download. Is ignored when a pathspec is provided.

content-type

string

yes

The media type (also known as a Multipurpose Internet Mail Extensions or MIME type) of the file. By default the value of the meta data field content-type will be used.

content-disposition

string

yes

The HTTP Response header indicating if the content is expected to be displayed inline in the browser, that is, as a Web page or as part of a Web page, or as an attachment, that is downloaded and saved locally. By default not set.

Saving a file

To save a file locally on disk the value of the content-disposition option needs to be set to attachment. By default the value of the field name in the metadata is used as filename. A custom filename can be defined in the value of the content-disposition option in the following way: attachment; filename=myname.jpg

Examples

Display in browser

Example to retrieve a file and to display the content in the browser. The authorization URL Query can be set to provide the Basic or Bearer authentication token.

HTTP GET

Request URL
Download from file property
  • /api/v2/downloadfile?pathspec=/Enterprise.Attachments&filter=favicon.ico

Download from GridFS
  • /api/v2/downloadfile?filestore=Lab&_id=5cf0e75c84b00a016000074c

Save file locally on disk

Example to save a file locally on disk with the same filename as stored in the system.

HTTP GET

Request URL
Download from file property
  • /api/v2/downloadfile?pathspec=/Enterprise.Attachments&filter=favicon.ico&content-disposition=attachment

Download from GridFS
  • /api/v2/downloadfile?filestore=Lab&_id=5cf0e75c84b00a016000074c&content-disposition=attachment

Save file locally with custom name

Example to save a file locally on disk with filename example.jpg.

HTTP GET

Request URL
Download from file property
  • /api/v2/downloadfile?pathspec=/Enterprise.Attachments&filter=favicon.ico&content-disposition=attachment; filename=example.jpg

Download from GridFS
  • /api/v2/downloadfile?filestore=Lab&_id=5cf0e75c84b00a016000074c&content-disposition=attachment; filename=example.jpg