Adapters. FilesAdapter

Members

supportsStreaming

Whether this adapter supports receiving Readable streams in createFile(). If false (default), streams are buffered to a Buffer before being passed. Override and return true to receive Readable streams directly.

Methods

createFile(filename, data, contentType, options) → {Promise}

Responsible for storing the file in order to be retrieved later by its filename

Parameters:
NameTypeDescription
filenamestring

the filename to save

dataBuffer | Readable

the file data as a Buffer, or a Readable stream if the adapter supports streaming (see supportsStreaming)

contentTypestring

the supposed contentType

optionsobject

(Optional) options to be passed to file adapter (S3 File Adapter Only)

  • tags: object containing key value pairs that will be stored with file
  • metadata: object containing key value pairs that will be sotred with file (https://docs.aws.amazon.com/AmazonS3/latest/user-guide/add-object-metadata.html)
Returns:

a promise that should fail if the storage didn't succeed

Type: 
Promise

deleteFile(filename) → {Promise}

Responsible for deleting the specified file

Parameters:
NameTypeDescription
filenamestring

the filename to delete

Returns:

a promise that should fail if the deletion didn't succeed

Type: 
Promise

getFileData(filename) → {Promise}

Responsible for retrieving the data of the specified file

Parameters:
NameTypeDescription
filenamestring

the name of file to retrieve

Returns:

a promise that should pass with the file data or fail on error

Type: 
Promise

getFileLocation(config, filename) → {string|Promise.<string>}

Returns an absolute URL where the file can be accessed

Parameters:
NameTypeDescription
configConfig

server configuration

filenamestring
Returns:

Absolute URL

Type: 
string | Promise.<string>