FsMediaProvider Class
A media provider that uses the underlying file system as the method of storage.
Constructor
FsMediaProvider
-
context
Parameters:
-
contextObject-
[parentDir]String optional -
siteString
-
Item Index
Methods
Methods
createWriteStream
-
mediaPath -
cb
Creates a writable stream to a file with the specified path. The resource is overwritten if already exists.
Parameters:
-
mediaPathStringThe path/key to the media. Typically this is a path such as: /media/2014/9/540a3ff0e30ddfb9e60000be-1409957872680.jpg
-
cbFunctionA callback that provides two parameters: An Error, if occurred and a WriteableStream.
delete
-
mediaPath -
cb
Deletes a file from the file system
Parameters:
-
mediaPathStringThe path/key to the media. Typically this is a path such as: /media/2014/9/540a3ff0e30ddfb9e60000be-1409957872680.jpg
-
cbFunctionA callback that provides two parameters: An Error, if occurred and the success of the operation.
exists
-
mediaPath -
cb
Checks to see if the file actually exists on disk
Parameters:
-
mediaPathStringThe path/key to the media. Typically this is a path such as: /media/2014/9/540a3ff0e30ddfb9e60000be-1409957872680.jpg
-
cbFunctionA callback that provides two parameters: An Error, if occurred and a Boolean.
get
-
mediaPath -
cb
Retrieves the content from the file system as a String or Buffer.
Parameters:
-
mediaPathStringThe path/key to the media. Typically this is a path such as: /media/2014/9/540a3ff0e30ddfb9e60000be-1409957872680.jpg
-
cbFunctionA callback that provides two parameters: An Error, if occurred and an entity that contains the media content.
getMediaPath
-
parentDir -
mediaPath
Generates an absolute path based on the parent directory and media path. The parent directory is expected to a single directory or set of directories nested under the pb.config.docRoot.
Parameters:
-
parentDirString -
mediaPathString
Returns:
Absolute path to the resource
getStream
-
mediaPath -
[options] -
cb
Retrieves the item on the file system as a stream.
Parameters:
-
mediaPathStringThe path/key to the media. Typically this is a path such as: /media/2014/9/540a3ff0e30ddfb9e60000be-1409957872680.jpg
-
[options]Object optionalOptions for interacting with S3
-
[bucket]String optionalThe S3 bucket to interact with
-
-
cbFunctionA callback that provides two parameters: An Error, if occurred and a ReadableStream that contains the media content.
mkdirs
-
absoluteFilePath -
A
Recursively creates the directory structure based on the absolute file path provided.
Parameters:
-
absoluteFilePathString -
AFunctioncallback that provides two parameters: Error, if occurred and result of the attempt at the creation of each directory in the path.
setStream
-
stream -
mediaPath -
cb
Sets media content into the file system based on the specified media path and options. The stream provided must be a ReadableStream.
Parameters:
-
streamReadableStreamThe content stream
-
mediaPathStringThe path/key to the media. Typically this is a path such as: /media/2014/9/540a3ff0e30ddfb9e60000be-1409957872680.jpg
-
cbFunctionA callback that provides two parameters: An Error, if occurred and the success of the operation.
setStream
-
fileDataStrOrBuffOrStream -
mediaPath -
cb
Sets media content into an file system based on the specified media path and options. The data must be in the form of a String or Buffer.
Parameters:
-
fileDataStrOrBuffOrStreamString | BufferThe content to persist
-
mediaPathStringThe path/key to the media. Typically this is a path such as: /media/2014/9/540a3ff0e30ddfb9e60000be-1409957872680.jpg
-
cbFunctionA callback that provides two parameters: An Error, if occurred and the success of the operation.
stat
-
mediaPath -
cb
Retrieve the stats on the file
Parameters:
-
mediaPathStringThe path/key to the media. Typically this is a path such as: /media/2014/9/540a3ff0e30ddfb9e60000be-1409957872680.jpg
-
cbFunctionA callback that provides two parameters: An Error, if occurred and an object that contains the file stats
