AbstractAsset

assets. AbstractAsset

Base class for handling an asset

Constructor

new AbstractAsset()

Source:

Members

(static) name :string

Source:
Name of the asset type
Type:
  • string

assetRoot :string

Source:
The root location for this asset type
Type:
  • string

ffmpeg :*

Source:
Reference to the ffmpeg module
Type:
  • *

ffprobe :*

Source:
Reference to the ffprobe module
Type:
  • *

hasThumb

Source:
Whether the asset has a thumbnail

isAudio

Source:
Whether the asset is an audio file

isImage

Source:
Whether the asset is an image file

isVideo

Source:
Whether the asset is an video file

path :string

Source:
The asset path
Type:
  • string

thumb

Source:
Access to the thumbnail asset

Methods

(async) delete() → {Promise}

Source:
Removes a file from the repository
Returns:
Type
Promise

(async) ensureDir(dir) → {Promise}

Source:
Ensures a directory exists, creating it if not. Must be overridden by subclasses.
Parameters:
Name Type Description
dir string Directory to check
Returns:
Type
Promise

(async) ensureExists() → {Promise}

Source:
Checks if a file exists. Must be overridden by subclasses.
Returns:
Rejects if not found
Type
Promise

(async) generateThumb(options)

Source:
Generate a thumbnail for an existing asset
Parameters:
Name Type Description
options object Optional settings
Properties
Name Type Description
regenerate string Will regenerate the thumbnail if one already exists

getFileExtension(file) → {String}

Source:
Returns the expected file type from a MIME subtype
Parameters:
Name Type Description
file FormidableFile File data
Returns:
Type
String

(async) move(newPath) → {Promise}

Source:
Parameters:
Name Type Description
newPath string New path for file
Returns:
Type
Promise

(async) read() → {external:stream~Readable}

Source:
Read a file. Must be overridden by subclasses.
Returns:
Type
external:stream~Readable

resolvePath(filePath) → {string}

Source:
Resolves a relative path to the root directory. Must be overridden by subclasses.
Parameters:
Name Type Description
filePath string
Returns:
The resolved path
Type
string

(async) updateFile(file) → {object}

Source:
Performs the required file operations when uploading/replacing an asset
Parameters:
Name Type Description
file FormidableFile Uploaded file data
Returns:
The update data
Type
object

(async) write(inputStream, outputPath) → {Promise}

Source:
Write a file to the repository. Must be overridden by subclasses.
Parameters:
Name Type Description
inputStream external:stream~Readable The file read stream
outputPath string Path at which to store the file
Returns:
Type
Promise

Type Definitions

generateMetadata

Source:
Sets metadata on an existing asset