Skip to content

Commit c45e4b0

Browse files
authored
Merge pull request #450 from spark/preservePath
Pass the preservePath down to Busboy
2 parents 60da983 + ee0f080 commit c45e4b0

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ Key | Description
9999
`dest` or `storage` | Where to store the files
100100
`fileFilter` | Function to control which files are accepted
101101
`limits` | Limits of the uploaded data
102+
`preservePath` | Keep the full path of files instead of just the base name
102103

103104
In an average web app, only `dest` might be required, and configured as shown in
104105
the following example.

index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ function Multer (options) {
1818
}
1919

2020
this.limits = options.limits
21+
this.preservePath = options.preservePath
2122
this.fileFilter = options.fileFilter || allowAll
2223
}
2324

@@ -45,6 +46,7 @@ Multer.prototype._makeMiddleware = function (fields, fileStrategy) {
4546

4647
return {
4748
limits: this.limits,
49+
preservePath: this.preservePath,
4850
storage: this.storage,
4951
fileFilter: wrappedFileFilter,
5052
fileStrategy: fileStrategy
@@ -74,6 +76,7 @@ Multer.prototype.any = function () {
7476
function setup () {
7577
return {
7678
limits: this.limits,
79+
preservePath: this.preservePath,
7780
storage: this.storage,
7881
fileFilter: this.fileFilter,
7982
fileStrategy: 'ARRAY'

lib/make-middleware.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,14 @@ function makeMiddleware (setup) {
2323
var storage = options.storage
2424
var fileFilter = options.fileFilter
2525
var fileStrategy = options.fileStrategy
26+
var preservePath = options.preservePath
2627

2728
req.body = Object.create(null)
2829

2930
var busboy
3031

3132
try {
32-
busboy = new Busboy({ headers: req.headers, limits: limits })
33+
busboy = new Busboy({ headers: req.headers, limits: limits, preservePath: preservePath })
3334
} catch (err) {
3435
return next(err)
3536
}

0 commit comments

Comments
 (0)