Creates a new file object which represents a file at the given id. Data which is provided to the constructor will be uploaded by invoking ()
The fileOptions used to create a new file object, or just the id of the file
Private [DATA]Private [ID]Private [METADATA]The database connection to use
Readonly isSpecifies whether this file is a folder.
The root bucket of this file
The creation date of the file, only accessible after fetching the metadata or downloading/uploading/providing the eTag
The eTag of the file, only accessible after fetching the metadata or downloading/uploading/providing the file
The custom headers of the file, only accessible after fetching the metadata or downloading/uploading/providing the file
The complete id of the file, including folder and name
Indicates if the metadata are loaded.
The full path under the bucket of this file
The last modified date of the file, only accessible after fetching the metadata or downloading/uploading/providing the eTag
The mimeType of the file, only accessible after fetching the metadata or downloading/uploading/providing the file
The name of the file
The parent folder of the file.
The full path of the file.
The size of the file, only accessible after fetching the metadata or downloading/uploading/providing the file
Private createCreates the file id from given options.
The fully url to the file, can be directly used to link the file, i.e. in link tags ot image sources
A url with an optional token, to give direct access o the linked resource
Optional authorize: booleanAuthorize the the link with an temporary token, to give authorized access to this protected resource default false if the root bucket is www, true otherwise
Deletes a file
A promise which will be fulfilled with this file object, or with a list of all deleted files, if this file is an folder
Optional deleteOptions: { The delete options
Optional force?: booleanOptional doneCallback: anyThe callback is invoked after the deletion succeed successfully
Optional failCallback: anyThe callback is invoked if any error is occurred
Download a file and providing it in the requested type
A promise which will be fulfilled with the downloaded file content
Optional downloadOptions: { The download options
Optional refresh?: falseOptional type?: ResponseBodyTypeOptional doneCallback: anyThe callback is invoked after the download succeed successfully
Optional failCallback: anyThe callback is invoked if any error is occurred
Private fromDeserialize the given JSON file metadata back to this file instance
If the JSON object contains an ID, it must match with this file ID, otherwise an exception is thrown.
The json to deserialize
Private guessPrivate
Gets the MIME type of given file options.
Returns the guessed MIME type or null, if it could not be guessed.
Gets the file metadata of a file
A promise which will be fulfilled with this file
Optional options: { The load metadata options
Optional refresh?: booleanForce a revalidation while fetching the metadata
Optional doneCallback: anyThe callback is invoked after the metadata is fetched
Optional failCallback: anyThe callback is invoked if any error has occurred
Updates the mata data of this file.
A promise which will be fulfilled with this file
Optional options: { The save metadata options
Optional force?: booleanforce the update and overwrite the existing metadata without validating it
Optional doneCallback: anyThe callback is invoked after the metadata is saved
Optional failCallback: anyThe callback is invoked if any error has occurred
Private setPrivate
Validates and sets the file metadata based on the given options
Uploads the file content which was provided in the constructor or by uploadOptions.data
A promise which will be fulfilled with this file object where the metadata is updated
Optional uploadOptions: FileData & FileMetadata & { The upload options
Optional doneCallback: anyThe callback is invoked after the upload succeed successfully
Optional failCallback: anyThe callback is invoked if any error is occurred
Static parseETagGenerated using TypeDoc
Creates a file object, which represents one specific file reference. This File object can afterwards be used to up- and download the file contents or to retrieves and change the files metadata.
The file data can be uploaded and downloaded as: