New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

multer-gridfs-storage

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

multer-gridfs-storage - npm Package Compare versions

Comparing version 0.0.3 to 0.0.5

LICENSE

30

lib/gridfs.js

@@ -13,17 +13,17 @@ var mongo = require('mongodb');

function getMetadata(req, file, cb) {
function noop(req, file, cb) {
cb(null, null);
}
function getIdentifier(req, file, cb) {
cb(null, null);
}
Storage.prototype._handleFile = function _handleFile(req, file, cb) {
var self = this;
var streamOpts = {
content_type: file.mimetype
content_type: file.mimetype,
chunkSize: self.chunkSize,
root: self.root
};
self.getIdentifier(req, file, function (err, id) {
if (id) {
if (err) {
return cb(err);
} else if (id) {
streamOpts._id = id;

@@ -34,8 +34,8 @@ }

if (err) {
cb(err);
return cb(err);
} else {
streamOpts.filename = filename;
self.getMetadata(req, file, function (metaErr, metadata) {
if (metaErr) {
cb(metaErr);
self.getMetadata(req, file, function (err, metadata) {
if (err) {
return cb(err);
} else {

@@ -95,5 +95,7 @@ streamOpts.metadata = metadata;

self.logLevel = opts.logLevel && opts.logLevel === 'all' ? opts.logLevel : 'file';
self.getIdentifier = (opts.identifier || getIdentifier);
self.getIdentifier = (opts.identifier || noop);
self.getFilename = (opts.filename || getFilename);
self.getMetadata = (opts.metadata || getMetadata);
self.getMetadata = (opts.metadata || noop);
self.chunkSize = (opts.chunkSize || 261120);
self.root = (opts.root || null);

@@ -135,2 +137,2 @@ if (!opts.gfs) {

module.exports = GridFSStorage;
module.exports = GridFSStorage;
{
"name": "multer-gridfs-storage",
"version": "0.0.3",
"version": "0.0.5",
"description": "Multer storage engine for GridFS",

@@ -21,2 +21,6 @@ "main": "index.js",

"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/devconcept/multer-gridfs-storage.git"
},
"devDependencies": {

@@ -26,2 +30,3 @@ "chai": "^3.5.0",

"chai-spies": "^0.7.1",
"coveralls": "^2.11.9",
"eslint": "^2.10.2",

@@ -31,7 +36,16 @@ "express": "^4.13.4",

"mocha": "^2.4.5",
"mocha-lcov-reporter": "^1.2.0",
"multer": "^1.1.0",
"supertest": "^1.2.0"
},
"engines": {
"node": ">= 0.10.0"
},
"bugs": {
"url": "https://github.com/devconcept/multer-gridfs-storage/issues"
},
"homepage": "https://github.com/devconcept/multer-gridfs-storage",
"files": [
"LICENSE",
"README.md",
"index.js",

@@ -38,0 +52,0 @@ "lib/"

@@ -58,7 +58,7 @@ # Multer GridFS storage engine

Required if `url` option is not present
Required if [`url`](https://github.com/devconcept/multer-gridfs-storage#url) option is not present
The [gridfs-stream](https://github.com/aheckmann/gridfs-stream/) instance to use.
If this option is provided files are stored using this stream. The connection should be opened or
If this option is provided files are stored using this stream. The connection should be open or
the module might fail to store incoming files since no connection test is made.

@@ -91,3 +91,3 @@ This option is useful when you have an existing GridFS object and want to reuse it to upload your files.

Required if `gfs` option is not present
Required if [`gfs`](https://github.com/devconcept/multer-gridfs-storage#gfs) option is not present

@@ -195,3 +195,3 @@ The mongodb connection uri.

parameters and can be used to change the default identifier ( the `_id` property)
created by MongoDb. Please note that you must guarantee that this value is unique
created by MongoDb. You must guarantee that this value is unique
otherwise you will get an error.

@@ -244,6 +244,49 @@

In this example the contents of the request body are stored with the file. Please note that
this is only for illustrative purposes. If your users send passwords or other sensitive data in the request
In this example the contents of the request body are stored with the file.
This is only for illustrative purposes. If your users send passwords or other sensitive data in the request
those will be stored unencrypted in the database as well, inside the metadata of the file.
#### chunkSize
Type: **Number**
Not required
The prefered size of file chunks. Default value is 261120.
Example:
```javascript
var storage = require('multer-gridfs-storage')({
url: 'mongodb://localhost:27017/database',
chunkSize: 2048
});
var upload = multer({ storage: storage });
```
#### root
Type: **String**
Not required
The root collection to store the files. By default this value is `null`.
Example:
```javascript
var storage = require('multer-gridfs-storage')({
url: 'mongodb://localhost:27017/database',
root: 'myfiles'
});
var upload = multer({ storage: storage });
```
Later on you can query the GridFS collection using
```javascript
db.collection('myfiles.files')//...
db.collection('myfiles.chunks')//...
```
#### log

@@ -378,2 +421,2 @@

[travis-url]: https://travis-ci.org/devconcept/multer-gridfs-storage
[travis-image]: https://img.shields.io/devconcept/multer-gridfs-storage/master.svg
[travis-image]: https://travis-ci.org/devconcept/multer-gridfs-storage.svg?branch=master
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