richardgirges / express-fileupload

Simple express file upload middleware that wraps around busboy
MIT License
1.52k stars 261 forks source link

How to pass additional parameters to .mv method? Like { mkdirp: true } #185

Closed 7iomka closed 4 years ago

7iomka commented 4 years ago

Hi. Without possibility to pass additional parameters to mv method i got errors, because output path not exist. MV lib for example have params mkdirp: true and that create recursively needed folders if not exist. Currently workaround is only with use tmp files like that mv(path.resolve(rootPath, tempFilePath), path.resolve(rootPath,src/assets/${mId}/${name}), { mkdirp: true }, err => {}) Any ideas? Thanks!

RomanBurunkov commented 4 years ago

I didn't quite catch the code you posted(probably it is about separate MV lib), but from the issue description, I believe you are asking about this option: createParentPath.

You should specify it in the middleware options like this:

app.use(fileUpload({
    useTempFiles : true,
    tempFileDir : '/tmp/',
    createParentPath: true
}));

Also be aware that to work properly this options needs node version 10 or higher.

7iomka commented 4 years ago

Oh. my carelessness, sorry! But still, as for me, this option should be enabled by default! Thanks!