Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

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.7 to 0.1.0

lab/alt.js

38

index.js

@@ -50,3 +50,7 @@ var os = require('os');

busboy.on('field', function(fieldname, val, valTruncated, keyTruncated) {
if (req.body.hasOwnProperty(fieldname)) {
// don't attach to the body object, if there is no value
if (!val) return;
if (req.body.hasOwnProperty(fieldname) && val) {
if (Array.isArray(req.body[fieldname])) {

@@ -60,2 +64,3 @@ req.body[fieldname].push(val);

}
});

@@ -68,14 +73,9 @@

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!
}
// don't attach to the files object, if there is file
if (!filename) return fileStream.resume();
ext = '.' + filename.split('.').slice(-1)[0];
newFilename = rename(fieldname, filename.replace(ext, '')) + ext;
newFilePath = path.join(dest, newFilename);
var file = {

@@ -139,5 +139,5 @@ fieldname: fieldname,

busboy.on('end', function() {
for (var field in req.files){
if (req.files[field].length===1){
busboy.on('finish', function() {
for (var field in req.files) {
if (req.files[field].length === 1) {
req.files[field] = req.files[field][0];

@@ -155,8 +155,6 @@ }

else {
return next();
}
else { return next(); }
};
}
};
}

@@ -1,26 +0,31 @@

/**
* Module dependencies.
*/
var express = require('express');
var routes = require('./routes');
var user = require('./routes/user');
var http = require('http');
var path = require('path');
var favicon = require('static-favicon');
var logger = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var debug = require('debug')('lab');
var routes = require('./routes/index');
var users = require('./routes/users');
var app = express();
// all environments
app.set('port', process.env.PORT || 3000);
// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'jade');
app.use(express.favicon());
app.use(express.logger('dev'));
app.use(express.json());
app.use(express.urlencoded());
app.use(express.methodOverride());
app.use(favicon());
app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded());
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));
var multer = require('../');
app.use(multer({
rename: function (fieldname, filename) {
return Date.now() + fieldname + filename;
},
onParseStart: function() {

@@ -38,21 +43,44 @@ console.log('STARTING ...');

app.use(app.router);
app.use(express.static(path.join(__dirname, 'public')));
app.use('/', routes);
app.use('/users', users);
// development only
if ('development' == app.get('env')) {
app.use(express.errorHandler());
/// catch 404 and forward to error handler
app.use(function(req, res, next) {
var err = new Error('Not Found');
err.status = 404;
next(err);
});
/// error handlers
// development error handler
// will print stacktrace
if (app.get('env') === 'development') {
app.use(function(err, req, res, next) {
res.status(err.status || 500);
res.render('error', {
message: err.message,
error: err
});
});
}
app.get('/', routes.index);
app.post('/', function(req, res) {
// production error handler
// no stacktraces leaked to user
app.use(function(err, req, res, next) {
res.status(err.status || 500);
res.render('error', {
message: err.message,
error: {}
});
});
console.log(req.body);
console.log(req.files);
res.send('OK');
module.exports = app;
app.set('port', process.env.PORT || 3000);
var server = app.listen(app.get('port'), function() {
debug('Express server listening on port ' + server.address().port);
});
http.createServer(app).listen(app.get('port'), function(){
console.log('Express server listening on port ' + app.get('port'));
});
{
"name": "application-name",
"name": "lab",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node app.js"
"start": "node ./bin/www"
},
"dependencies": {
"express": "3.4.8",
"jade": "*"
"express": "^4.3.2",
"static-favicon": "~1.0.0",
"morgan": "~1.0.0",
"cookie-parser": "~1.0.1",
"body-parser": "~1.0.0",
"debug": "~0.7.4",
"jade": "~1.3.0",
"busboy": "^0.2.6",
"connect-busboy": "0.0.1"
}
}
}

@@ -0,8 +1,18 @@

var express = require('express');
var router = express.Router();
var Busboy = require('busboy');
/*
* GET home page.
*/
/* GET home page. */
router.get('/', function(req, res) {
res.render('index', { title: 'Express' });
});
exports.index = function(req, res){
res.render('index', { title: 'Express' });
};
router.post('/', function(req, res) {
console.log(req.body);
console.log(req.files);
res.send('OK');
});
module.exports = router;
{
"name": "multer",
"version": "0.0.7",
"version": "0.1.0",
"description": "Connect middleware for handling multipart/form-data",

@@ -29,3 +29,3 @@ "main": "index.js",

"mkdirp": "~0.3.5",
"busboy": "0.0.14"
"busboy": "^0.2.6"
},

@@ -32,0 +32,0 @@ "devDependencies": {

Sorry, the diff of this file is not supported yet

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