express-fileupload
Advanced tools
Comparing version 1.1.6-alpha.5 to 1.1.6-alpha.6
@@ -11,4 +11,3 @@ const Busboy = require('busboy'); | ||
buildOptions, | ||
parseFileName, | ||
uriDecodeFileName | ||
parseFileName | ||
} = require('./utilities'); | ||
@@ -48,4 +47,4 @@ | ||
const timeout = options.uploadTimeout; | ||
// Decode file name if uriDecodeFileNames option set true. | ||
const filename = uriDecodeFileName(options, name); | ||
// Parse file name(cutting huge names, decoding, etc..). | ||
const filename = parseFileName(options, name); | ||
// Define methods and handlers for upload process. | ||
@@ -89,3 +88,3 @@ const {dataHandler, getFilePath, getFileSize, getHash, complete, cleanup} = options.useTempFiles | ||
buffer: complete(), | ||
name: parseFileName(options, filename), | ||
name: filename, | ||
tempFilePath: getFilePath(), | ||
@@ -92,0 +91,0 @@ size: getFileSize(), |
@@ -241,3 +241,8 @@ 'use strict'; | ||
const parseFileName = (opts, fileName) => { | ||
if (!opts.safeFileNames) return fileName; | ||
// Cut off file name if it's lenght more then 255. | ||
let parsedName = fileName.length <= 255 ? fileName : fileName.substr(0, 255); | ||
// Decode file name if uriDecodeFileNames option set true. | ||
parsedName = uriDecodeFileName(opts, parsedName); | ||
// Stop parsing file name if safeFileNames options hasn't been set. | ||
if (!opts.safeFileNames) return parsedName; | ||
// Set regular expression for the file name. | ||
@@ -248,3 +253,3 @@ const nameRegex = typeof opts.safeFileNames === 'object' && opts.safeFileNames instanceof RegExp | ||
// Parse file name extension. | ||
let {name, extension} = parseFileNameExtension(opts.preserveExtension, fileName); | ||
let {name, extension} = parseFileNameExtension(opts.preserveExtension, parsedName); | ||
if (extension.length) extension = '.' + extension.replace(nameRegex, ''); | ||
@@ -251,0 +256,0 @@ |
{ | ||
"name": "express-fileupload", | ||
"version": "1.1.6-alpha.5", | ||
"version": "1.1.6-alpha.6", | ||
"author": "Richard Girges <richardgirges@gmail.com>", | ||
@@ -8,3 +8,3 @@ "description": "Simple express file upload middleware that wraps around Busboy", | ||
"scripts": { | ||
"test": "istanbul cover _mocha -- -R spec", | ||
"test": "istanbul cover node_modules/mocha/bin/_mocha -- -R spec", | ||
"lint": "eslint ./", | ||
@@ -14,3 +14,3 @@ "coveralls": "cat ./coverage/lcov.info | coveralls" | ||
"dependencies": { | ||
"busboy": "^0.2.14" | ||
"busboy": "^0.3.1" | ||
}, | ||
@@ -17,0 +17,0 @@ "engines": { |
@@ -9,10 +9,2 @@ # express-fileupload | ||
# Version 1.1.1 Breaking Changes | ||
Breaking change to `md5` handling: | ||
* `md5` value contains md5 hash instead of a function to compute it. | ||
* `md5` now can be used with `useTempFiles: true`. | ||
# Version 1.0.0 Breaking Changes | ||
Breaking change to `md5` handling. [Read about it here.](https://github.com/richardgirges/express-fileupload/releases/tag/v1.0.0-alpha.1) | ||
# Install | ||
@@ -50,2 +42,9 @@ ```bash | ||
**Notes about braking changes with md5 handling:** | ||
* Before 1.0.0 `md5` is a MD5 checksum of the uploaded file. | ||
* In 1.0.0 and till 1.1.1 `md5` value is a function to compute md5 hash [Read about it here.](https://github.com/richardgirges/express-fileupload/releases/tag/v1.0.0-alpha.1) | ||
* From 1.1.1 it was reverted back to MD5 checksum value and also added full md5 support in case of using temporary files. | ||
### Examples | ||
@@ -68,2 +67,6 @@ * [Example Project](https://github.com/richardgirges/express-fileupload/tree/master/example) | ||
``` | ||
Note that this option available for versions 1.0.0 and newer. | ||
``` | ||
```javascript | ||
@@ -75,3 +78,29 @@ app.use(fileUpload({ | ||
``` | ||
### Using debug option | ||
You can set `debug` option to `true` to see some logging about upload process. | ||
In this case middleware uses `console.log` and adds `Express-file-upload` prefix for outputs. | ||
It will show you whether the request is illigable and also common events triggered during upload. | ||
That can be really usfull for troubleshhoting and ***we recommend to attach debug output to each issue on Github***. | ||
***Output example:*** | ||
``` | ||
Express-file-upload: Temporary file path is /node/express-fileupload/test/temp/tmp-16-1570084843942 | ||
Express-file-upload: New upload started testFile->car.png, bytes:0 | ||
Express-file-upload: Uploading testFile->car.png, bytes:21232... | ||
Express-file-upload: Uploading testFile->car.png, bytes:86768... | ||
Express-file-upload: Upload timeout testFile->car.png, bytes:86768 | ||
Express-file-upload: Cleaning up temporary file /node/express-fileupload/test/temp/tmp-16-1570084843942... | ||
``` | ||
***Description:*** | ||
* `Temporary file path is...` says that `useTempfiles` was set to true and also shows you temp file name and path. | ||
* `New upload started testFile->car.png` says that new upload started with field `testFile` and file name `car.png`. | ||
* `Uploading testFile->car.png, bytes:21232...` shows current progress for each new data chunk. | ||
* `Upload timeout` means that no data came during `uploadTimeout`. | ||
* `Cleaning up temporary file` Here finaly we see cleaning up of the temporary file because of upload timeout reached. | ||
### Available Options | ||
@@ -78,0 +107,0 @@ Pass in non-Busboy options directly to the middleware. These are express-fileupload specific options. |
@@ -133,2 +133,8 @@ 'use strict'; | ||
it('Cuts of file name length if it more then 255 chars.', () => { | ||
const name = 'a'.repeat(300); | ||
const result = parseFileName({}, name); | ||
assert.equal(result.length, 255); | ||
}); | ||
it( | ||
@@ -135,0 +141,0 @@ 'Strips away all non-alphanumeric characters (excluding hyphens/underscores) when enabled.', |
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
1208678
2170
124
+ Addedbusboy@0.3.1(transitive)
+ Addeddicer@0.3.0(transitive)
- Removedbusboy@0.2.14(transitive)
- Removedcore-util-is@1.0.3(transitive)
- Removeddicer@0.2.5(transitive)
- Removedinherits@2.0.4(transitive)
- Removedisarray@0.0.1(transitive)
- Removedreadable-stream@1.1.14(transitive)
- Removedstring_decoder@0.10.31(transitive)
Updatedbusboy@^0.3.1