Skip to content

Commit

Permalink
Merge pull request #450 from spark/preservePath
Browse files Browse the repository at this point in the history
Pass the preservePath down to Busboy
  • Loading branch information
LinusU authored Jan 25, 2017
2 parents 60da983 + ee0f080 commit c45e4b0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ Key | Description
`dest` or `storage` | Where to store the files
`fileFilter` | Function to control which files are accepted
`limits` | Limits of the uploaded data
`preservePath` | Keep the full path of files instead of just the base name

In an average web app, only `dest` might be required, and configured as shown in
the following example.
Expand Down
3 changes: 3 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ function Multer (options) {
}

this.limits = options.limits
this.preservePath = options.preservePath
this.fileFilter = options.fileFilter || allowAll
}

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

return {
limits: this.limits,
preservePath: this.preservePath,
storage: this.storage,
fileFilter: wrappedFileFilter,
fileStrategy: fileStrategy
Expand Down Expand Up @@ -74,6 +76,7 @@ Multer.prototype.any = function () {
function setup () {
return {
limits: this.limits,
preservePath: this.preservePath,
storage: this.storage,
fileFilter: this.fileFilter,
fileStrategy: 'ARRAY'
Expand Down
3 changes: 2 additions & 1 deletion lib/make-middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@ function makeMiddleware (setup) {
var storage = options.storage
var fileFilter = options.fileFilter
var fileStrategy = options.fileStrategy
var preservePath = options.preservePath

req.body = Object.create(null)

var busboy

try {
busboy = new Busboy({ headers: req.headers, limits: limits })
busboy = new Busboy({ headers: req.headers, limits: limits, preservePath: preservePath })
} catch (err) {
return next(err)
}
Expand Down

0 comments on commit c45e4b0

Please sign in to comment.