* 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`
(
filename: string,
options?: GridFSBucketReadStreamOptionsWithRevision
)
| 201 | * option to change this behavior. |
| 202 | */ |
| 203 | openDownloadStreamByName( |
| 204 | filename: string, |
| 205 | options?: GridFSBucketReadStreamOptionsWithRevision |
| 206 | ): GridFSBucketReadStream { |
| 207 | let sort: Sort = { uploadDate: -1 }; |
| 208 | let skip = undefined; |
| 209 | if (options && options.revision != null) { |
| 210 | if (options.revision >= 0) { |
| 211 | sort = { uploadDate: 1 }; |
| 212 | skip = options.revision; |
| 213 | } else { |
| 214 | skip = -options.revision - 1; |
| 215 | } |
| 216 | } |
| 217 | return new GridFSBucketReadStream( |
| 218 | this.s._chunksCollection, |
| 219 | this.s._filesCollection, |
| 220 | this.s.options.readPreference, |
| 221 | { filename }, |
| 222 | { timeoutMS: this.s.options.timeoutMS, ...options, sort, skip } |
| 223 | ); |
| 224 | } |
| 225 | |
| 226 | /** |
| 227 | * Renames the file with the given _id to the given string |
no outgoing calls