mongoose-gridfs
Advanced tools
Comparing version 0.3.2 to 0.4.0
@@ -116,2 +116,23 @@ 'use strict'; | ||
/** | ||
* @function | ||
* @name readByFileName | ||
* @param {String} filename valid file name | ||
* @param {Function} done a callback to invoke on success or error | ||
* @return {stream.Readable} | ||
* @public | ||
* @example | ||
* Attachment.readByFileName(<filename>,function(error, fileContent){ | ||
* ... | ||
* }); | ||
* | ||
* or for larger file size | ||
* | ||
* const stream = Attachment.readByFileName(<filename>); | ||
*/ | ||
GridFSSchema.statics.readByFileName = function (filename, done) { | ||
return this.gridfs.readByFileName(filename, done); | ||
}; | ||
@@ -118,0 +139,0 @@ /** |
@@ -291,2 +291,42 @@ 'use strict'; | ||
/** | ||
* @function | ||
* @name readByFileName | ||
* @param {String} filename valid file name | ||
* @param {Function} [done] a callback to invoke on success or error. | ||
* Pass callback if filesize is small enough. | ||
* Otherwise consider using stream instead. | ||
* @return {stream.Readable} | ||
* @public | ||
* @example | ||
* const readableStream = gridfs.readByFileName("my_file.txt"); | ||
* | ||
* gridfs.readByFileName("my_file.txt"}); | ||
*/ | ||
GridFSStorage.prototype.readByFileName = function (filename, done) { | ||
//obtain collection | ||
const collection = this.options.collection; | ||
//prepare file remove options | ||
const options = { | ||
filename: filename, | ||
root: collection | ||
}; | ||
//create a readable stream for a specific file | ||
const stream = this.storage.createReadStream(options); | ||
//pipe the whole stream into buffer if callback provided | ||
if (done && _.isFunction(done)) { | ||
read(stream, done); | ||
} | ||
//return stream | ||
else { | ||
return stream; | ||
} | ||
}; | ||
//multer GridFS storage implementation | ||
@@ -293,0 +333,0 @@ |
{ | ||
"name": "mongoose-gridfs", | ||
"version": "0.3.2", | ||
"version": "0.4.0", | ||
"description": "mongoose gridfs on top of gridfs-stream", | ||
@@ -32,4 +32,4 @@ "main": "index.js", | ||
"dependencies": { | ||
"gridfs-stream": "^1.1.1", | ||
"lodash": "^4.17.4", | ||
"gridfs-stream": "git+https://github.com/lykmapipo/gridfs-stream.git", | ||
"lodash": "^4.17.10", | ||
"stream-read": "^1.1.2" | ||
@@ -40,17 +40,17 @@ }, | ||
"chai": "^4.1.2", | ||
"grunt": "^1.0.1", | ||
"grunt": "^1.0.2", | ||
"grunt-contrib-jshint": "^1.1.0", | ||
"grunt-contrib-watch": "^1.0.0", | ||
"grunt-contrib-watch": "^1.1.0", | ||
"grunt-mocha-test": "^0.13.3", | ||
"is-stream": "^1.1.0", | ||
"jshint-stylish": "^2.2.1", | ||
"load-grunt-tasks": "^3.5.2", | ||
"mime": "^2.0.3", | ||
"mocha": "^4.0.1", | ||
"mongoose": "^4.13.4" | ||
"load-grunt-tasks": "^4.0.0", | ||
"mime": "^2.3.1", | ||
"mocha": "^5.1.1", | ||
"mongoose": "^5.1.0" | ||
}, | ||
"engines": { | ||
"node": "8.6.0", | ||
"npm": "5.3.0" | ||
"node": ">=8.6.0", | ||
"npm": ">=5.3.0" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Git dependency
Supply chain riskContains a dependency which resolves to a remote git URL. Dependencies fetched from git URLs are not immutable can be used to inject untrusted code or reduce the likelihood of a reproducible install.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
21904
534
1
- Removedflushwritable@1.0.0(transitive)
- Removedgridfs-stream@1.1.1(transitive)
Updatedgridfs-stream@git+https://github.com/lykmapipo/gridfs-stream.git
Updatedlodash@^4.17.10