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

express-fileupload

Package Overview
Dependencies
Maintainers
1
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-fileupload - npm Package Compare versions

Comparing version 1.1.1-alpha.2 to 1.1.1-alpha.3

lib/memHandler.js

5

lib/fileFactory.js

@@ -12,2 +12,3 @@ 'use strict';

data: options.buffer,
size: options.size,
encoding: options.encoding,

@@ -96,7 +97,3 @@ tempFilePath: options.tempFilePath,

if (options.size) {
output.size = options.size;
}
return output;
};

31

lib/processMultipart.js
const Busboy = require('busboy');
const fileFactory = require('./fileFactory');
const {tempFileHandler} = require('./tempFileHandler');
const memHandler = require('./memHandler');
const tempFileHandler = require('./tempFileHandler');
const processNested = require('./processNested');

@@ -54,18 +55,7 @@

busboy.on('file', function(fieldname, file, filename, encoding, mime) {
const buffers = [];
let safeFileNameRegex = /[^\w-]/g;
const memHandler = function(data) {
buffers.push(data);
if (options.debug) {
return console.log('Uploading %s -> %s', fieldname, filename); // eslint-disable-line
}
};
const tempHandlerGen = tempFileHandler(options, fieldname, filename);
const {getTempFilePath, complete, cleanupStream} = tempHandlerGen;
const {dataHandler, getFilePath, getFileSize, complete, cleanup} = options.useTempFiles
? tempFileHandler(options, fieldname, filename)
: memHandler(options, fieldname, filename);
const dataHandler = options.useTempFiles
? tempHandlerGen.handler
: memHandler;
file.on('limit', () => {

@@ -84,7 +74,4 @@ if (options.abortOnLimit) {

}
if (options.useTempFiles) {
complete(filename);
}
const buffer = Buffer.concat(buffers);
const buffer = complete(filename);
// see: https://github.com/richardgirges/express-fileupload/issues/14

@@ -98,2 +85,3 @@ // firefox uploads empty file in case of cache miss when f5ing page.

if (options.safeFileNames) {
let safeFileNameRegex = /[^\w-]/g;
let maxExtensionLength = 3;

@@ -143,3 +131,4 @@ let extension = '';

buffer,
tempFilePath: getTempFilePath(),
tempFilePath: getFilePath(),
size: getFileSize(),
encoding,

@@ -165,3 +154,3 @@ truncated: file.truncated,

file.on('error', cleanupStream, next);
file.on('error', cleanup, next);
});

@@ -168,0 +157,0 @@

const fs = require('fs');
const path = require('path');
module.exports.tempFileHandler = function(options, fieldname, filename) {
module.exports = function(options, fieldname, filename) {
const dir = path.normalize(options.tempFileDir || process.cwd() + '/tmp/');

@@ -15,3 +15,3 @@

return {
handler: function(data) {
dataHandler: function(data) {
writeStream.write(data);

@@ -27,6 +27,9 @@ fileSize += data.length;

},
getTempFilePath: function(){
getFilePath: function(){
return tempFilePath;
},
cleanupStream: function(){
getFileSize: function(){
return fileSize;
},
cleanup: function(){
writeStream.end();

@@ -40,4 +43,5 @@

writeStream.end();
return Buffer.concat([]); //return empty buffer since uploaded to the temporary file.
}
};
};
{
"name": "express-fileupload",
"version": "1.1.1-alpha.2",
"version": "1.1.1-alpha.3",
"author": "Richard Girges <richardgirges@gmail.com>",

@@ -5,0 +5,0 @@ "description": "Simple express file upload middleware that wraps around Busboy",

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