FsMediaProvider Class
A media provider that uses the underlying file system as the method of storage.
Constructor
FsMediaProvider
-
context
Parameters:
-
context
Object-
[parentDir]
String optional -
site
String
-
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:
-
mediaPath
StringThe path/key to the media. Typically this is a path such as: /media/2014/9/540a3ff0e30ddfb9e60000be-1409957872680.jpg
-
cb
FunctionA callback that provides two parameters: An Error, if occurred and a WriteableStream.
delete
-
mediaPath
-
cb
Deletes a file from the file system
Parameters:
-
mediaPath
StringThe path/key to the media. Typically this is a path such as: /media/2014/9/540a3ff0e30ddfb9e60000be-1409957872680.jpg
-
cb
FunctionA 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:
-
mediaPath
StringThe path/key to the media. Typically this is a path such as: /media/2014/9/540a3ff0e30ddfb9e60000be-1409957872680.jpg
-
cb
FunctionA 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:
-
mediaPath
StringThe path/key to the media. Typically this is a path such as: /media/2014/9/540a3ff0e30ddfb9e60000be-1409957872680.jpg
-
cb
FunctionA 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:
-
parentDir
String -
mediaPath
String
Returns:
Absolute path to the resource
getStream
-
mediaPath
-
[options]
-
cb
Retrieves the item on the file system as a stream.
Parameters:
-
mediaPath
StringThe 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
-
-
cb
FunctionA 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:
-
absoluteFilePath
String -
A
Functioncallback 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:
-
stream
ReadableStreamThe content stream
-
mediaPath
StringThe path/key to the media. Typically this is a path such as: /media/2014/9/540a3ff0e30ddfb9e60000be-1409957872680.jpg
-
cb
FunctionA 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:
-
fileDataStrOrBuffOrStream
String | BufferThe content to persist
-
mediaPath
StringThe path/key to the media. Typically this is a path such as: /media/2014/9/540a3ff0e30ddfb9e60000be-1409957872680.jpg
-
cb
FunctionA 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:
-
mediaPath
StringThe path/key to the media. Typically this is a path such as: /media/2014/9/540a3ff0e30ddfb9e60000be-1409957872680.jpg
-
cb
FunctionA callback that provides two parameters: An Error, if occurred and an object that contains the file stats