Socket
Socket
Sign inDemoInstall

multer

Package Overview
Dependencies
Maintainers
1
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

multer - npm Package Compare versions

Comparing version 0.0.4 to 0.0.5

lab/images/00a1083442a767a57a5594b89f6bd198.txt

42

index.js
var os = require('os');
var fs = require('fs');
var path = require('path');
var crypto = require('crypto');

@@ -13,6 +14,9 @@ var Busboy = require('busboy');

var dest;
// some users may ommit the trailing slash
if (options.dest) { dest = options.dest.slice(-1) == '/' ? options.dest : options.dest + '/'; }
else { dest = os.tmpdir(); }
if (options.dest) {
dest = options.dest;
} else {
dest = os.tmpdir();
}
// make sure the dest dir exists

@@ -45,3 +49,11 @@ mkdirp(dest, function(err) { if (err) throw err; });

busboy.on('field', function(fieldname, val, valTruncated, keyTruncated) {
req.body[fieldname] = val;
if (req.body.hasOwnProperty(fieldname)) {
if (Array.isArray(req.body)) {
req.body[fieldname].push(val);
} else {
req.body[fieldname] = [req.body[fieldname], val];
}
} else {
req.body[fieldname] = val;
}
});

@@ -52,6 +64,16 @@

var ext = '.' + filename.split('.').slice(-1)[0];
var newFilename = rename(fieldname, filename.replace(ext, '')) + ext;
var path = dest + newFilename;
var ext, newFilename, newFilePath;
if (filename) {
ext = '.' + filename.split('.').slice(-1)[0];
newFilename = rename(fieldname, filename.replace(ext, '')) + ext;
newFilePath = path.join(dest, newFilename);
}
else {
filename = null;
ext = null;
newFilename = null;
newFilePath = '/dev/null'; // do something for Windows!
}
var file = {

@@ -63,4 +85,4 @@ fieldname: fieldname,

mimetype: mimetype,
path: path,
extension: ext.replace('.', '')
path: newFilePath,
extension: (ext === null) ? null : ext.replace('.', '')
};

@@ -71,3 +93,3 @@

var ws = fs.createWriteStream(path);
var ws = fs.createWriteStream(newFilePath);
fileStream.pipe(ws);

@@ -74,0 +96,0 @@

{
"name": "multer",
"version": "0.0.4",
"version": "0.0.5",
"description": "Connect middleware for handling multipart/form-data",

@@ -5,0 +5,0 @@ "main": "index.js",

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