Store

flitter-upload/store/Store~ Store

Abstract class representing a backend for storing and retrieving uploaded files.


Constructor

(abstract) new Store(config)

Instantiate the store.

Parameters:
Name Type Description
config object

the store's configuration

Extends

Members

(private) _di_allow_defer :boolean

If true, the injector will defer the class if the class requests any services that the container is missing. These services are filled in later and added to the prototype and any instances. True by default.

Type:
  • boolean

(private) _di_deferred_instances :Array.<module:flitter-di/src/Injectable~Injectable>

Collection of instances of this class that need to have the deferred service instances injected into them when the deferred services are finally provided.

(private) _di_deferred_services :Array.<string>

List of services that were deferred and not provided at the time of injection.

Type:
  • Array.<string>

config :object

The configuration for this store.

Type:
  • object

Methods

(async) download_file(file, destination) → {Promise.<void>}

Download the file locally to the destination path.

Parameters:
Name Type Description
file module:flitter-upload/model/File~File
destination string
Returns:
Type
Promise.<void>

(async) init() → {Promise.<void>}

Initializes the store. Called once when the application is started. This is where any logic required to connect to, prepare, or guarantee the store is ready to use should occur.

Returns:
Type
Promise.<void>

read_stream(file) → {ReadStream}

Create a Readable stream for this file.

Parameters:
Name Type Description
file module:flitter-upload/model/File~File
Returns:
Type
ReadStream

(async, abstract) send_file(file, response) → {Promise.<void>}

Send the specified file as the data for the response. This should set the appropriate Content-Type and Content-Disposition headers.

Parameters:
Name Type Description
file module:flitter-upload/model/File~File

the file to send

response express/response

the response

Returns:
Type
Promise.<void>

(async, abstract) store(params) → {Promise.<module:flitter-upload/model/File~File>}

Permanently store a temporarily uploaded file in this store.

Parameters:
Name Type Description
params object
Properties
Name Type Description
temp_path string

absolute path to the temporarily uploaded file

original_name string

the original upload name of the file

mime_type string

the MIME type of the file.

Returns:
Type
Promise.<module:flitter-upload/model/File~File>