Socket
Socket
Sign inDemoInstall

mongoose-gridfs

Package Overview
Dependencies
Maintainers
1
Versions
70
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mongoose-gridfs - npm Package Compare versions

Comparing version 0.3.2 to 0.4.0

21

lib/schema.js

@@ -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 @@

22

package.json
{
"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"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc