Socket
Socket
Sign inDemoInstall

multer

Package Overview
Dependencies
Maintainers
3
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 2.0.0-alpha.3 to 2.0.0-alpha.4

17

CHANGELOG.md

@@ -6,2 +6,19 @@ # Change log

## 2.0.0-alpha.4 - 2017-02-14
- Feature: add file type detection
## 2.0.0-alpha.3 - 2016-12-22
- Feature: unlink file as soon as it's opened
## 2.0.0-alpha.2 - 2016-10-02
- Feature: use LIMIT_FILE_COUNT when receiving too many files
## 2.0.0-alpha.1 - 2016-10-01
- Feature: switch to stream based API
- Feature: throw error when passing old options
## 1.2.0 - 2016-08-04

@@ -8,0 +25,0 @@

11

lib/middleware.js

@@ -25,14 +25,9 @@ var is = require('type-is')

result.files.forEach(function (file) {
var stream = fs.createReadStream(file.path)
file.stream = fs.createReadStream(file.path)
stream.on('open', function () {
file.stream.on('open', function () {
fs.unlink(file.path, function () {})
})
appendFile({
fieldName: file.fieldName,
originalName: file.originalName,
size: file.size,
stream: stream
})
appendFile(file)
})

@@ -39,0 +34,0 @@

@@ -0,4 +1,6 @@

var path = require('path')
var pify = require('pify')
var temp = require('fs-temp')
var Busboy = require('busboy')
var FileType = require('stream-file-type')

@@ -54,3 +56,5 @@ var pump = pify(require('pump'))

fieldName: fieldname,
originalName: filename
originalName: filename,
clientReportedMimeType: mimetype,
clientReportedFileExtension: path.extname(filename)
}

@@ -72,2 +76,3 @@

var target = temp.createWriteStream()
var detector = new FileType()

@@ -78,3 +83,3 @@ var fileClosed = new Promise(function (resolve) {

var promise = pump(fileStream, target)
var promise = pump(fileStream, detector, target)
.then(function () {

@@ -84,4 +89,9 @@ return fileClosed

.then(function () {
return detector.fileTypePromise()
})
.then(function (fileType) {
file.path = target.path
file.size = target.bytesWritten
file.detectedMimeType = (fileType ? fileType.mime : null)
file.detectedFileExtension = (fileType ? '.' + fileType.ext : '')
return file

@@ -88,0 +98,0 @@ })

{
"name": "multer",
"description": "Middleware for handling `multipart/form-data`.",
"version": "2.0.0-alpha.3",
"version": "2.0.0-alpha.4",
"contributors": [

@@ -28,2 +28,3 @@ "Hage Yaapa <captain@hacksparrow.com> (http://www.hacksparrow.com)",

"pump": "^1.0.1",
"stream-file-type": "^0.1.1",
"type-is": "^1.6.13"

@@ -42,3 +43,3 @@ },

"engines": {
"node": ">= 0.12.0"
"node": ">= 4.0.0"
},

@@ -45,0 +46,0 @@ "files": [

@@ -75,3 +75,9 @@ # Multer [![Build Status](https://travis-ci.org/expressjs/multer.svg?branch=master)](https://travis-ci.org/expressjs/multer) [![NPM version](https://badge.fury.io/js/multer.svg)](https://badge.fury.io/js/multer) [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://github.com/feross/standard)

`stream` | Stream of file
`detectedMimeType` | The detected mime-type, or null if we failed to detect
`detectedFileExtension` | The typical file extension for files of the detected type, or empty string if we failed to detect (with leading `.` to match `path.extname`)
`clientReportedMimeType` | The mime type reported by the client using the `Content-Type` header, or null<sup>1</sup> if the header was absent
`clientReportedFileExtension` | The extension of the file uploaded (as reported by `path.extname`)
<sup>1</sup> Currently returns `text/plain` if header is absent, this is a bug and it will be fixed in a patch release. Do not rely on this behavior.
### `multer(opts)`

@@ -78,0 +84,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