Constructor for a streaming GridFS interface
Name Type Descriptiondb
Db
A db handle
options
object optional
Optional settings.
Name Type Default DescriptionbucketName
string "fs" optional
The 'files' and 'chunks' collections will be prefixed with the bucket name followed by a dot.
chunkSizeBytes
number 255 * 1024 optional
Number of bytes stored in each chunk. Defaults to 255KB
writeConcern
object optional
Optional write concern to be passed to write operations, for instance { w: 1 }
readPreference
object optional
Optional read preference to be passed to read operations
Deletes a file with the given id
Removes this bucket's files collection, followed by its chunks collection.
Convenience wrapper around find on the files collection
Name Type Descriptionfilter
Object options
Object optional
Optional settings for cursor
Name Type Default DescriptionbatchSize
number 1000 optional
The number of documents to return per batch. See find command documentation.
limit
number optional
Optional limit for cursor
maxTimeMS
number optional
Optional maxTimeMS for cursor
noCursorTimeout
boolean optional
Optionally set cursor's noCursorTimeout
flag
skip
number optional
Optional skip for cursor
sort
object optional
Optional sort for cursor
Returns a readable stream (GridFSBucketReadStream) for streaming file
data from GridFS.
id
ObjectId
The id of the file doc
options
Object optional
Optional settings.
Name Type Descriptionstart
Number optional
Optional 0-based offset in bytes to start streaming from
end
Number optional
Optional 0-based offset in bytes to stop streaming before
Returns a readable stream (GridFSBucketReadStream) for streaming the
file with the given name from GridFS. If there are multiple files with
the same name, this will stream the most recent file with the given name
(as determined by the uploadDate
field). You can set the revision
option to change this behavior.
filename
String
The name of the file to stream
options
Object optional
Optional settings
Name Type Default Descriptionrevision
number -1 optional
The revision number relative to the oldest file with the given filename. 0 gets you the oldest file, 1 gets you the 2nd oldest, -1 gets you the newest.
start
Number optional
Optional 0-based offset in bytes to start streaming from
end
Number optional
Optional 0-based offset in bytes to stop streaming before
Returns a writable stream (GridFSBucketWriteStream) for writing
buffers to GridFS. The stream's 'id' property contains the resulting
file's id.
filename
string
The value of the 'filename' key in the files doc
options
object optional
Optional settings.
Name Type Default DescriptionchunkSizeBytes
number optional
Optional overwrite this bucket's chunkSizeBytes for this file
metadata
object optional
Optional object to store in the file document's metadata
field
contentType
string optional
Optional string to store in the file document's contentType
field
aliases
array optional
Optional array of strings to store in the file document's aliases
field
disableMD5
boolean false optional
If true, disables adding an md5 field to file data
Returns a writable stream (GridFSBucketWriteStream) for writing
buffers to GridFS for a custom file id. The stream's 'id' property contains the resulting
file's id.
id
string | number | object
A custom id used to identify the file
filename
string
The value of the 'filename' key in the files doc
options
object optional
Optional settings.
Name Type Default DescriptionchunkSizeBytes
number optional
Optional overwrite this bucket's chunkSizeBytes for this file
metadata
object optional
Optional object to store in the file document's metadata
field
contentType
string optional
Optional string to store in the file document's contentType
field
aliases
array optional
Optional array of strings to store in the file document's aliases
field
disableMD5
boolean false optional
If true, disables adding an md5 field to file data
Renames the file with the given _id to the given string
Name Type Descriptionid
ObjectId
the id of the file to rename
filename
String
new name for the file
callback
GridFSBucket~errorCallback optional
Callback format for all GridFSBucket methods that can accept a callback.
Name Type Descriptionerror
MongoError | undefined
If present, an error instance representing any errors that occurred
result
*
If present, a returned result for the method
When the first call to openUploadStream is made, the upload stream will
check to see if it needs to create the proper indexes on the chunks and
files collections. This event is fired either when 1) it determines that
no index creation is necessary, 2) when it successfully creates the
necessary indexes.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4