Comments (13)
@KIDx Could you please provide a more thorough test case?
from multer.
@Fishrock123 , Here is my code.
exports.dataUpload = function(req, res) {
res.header('Content-Type', 'text/plain');
if (!req.files || !req.files.data) {
return res.end();
}
var path = req.files.data.path
, fname = req.files.data.name
, sz = req.files.data.size
, pid = parseInt(req.query.pid, 10);
var RP = function(s) {
fs.unlink(path, function(){
return res.end(s);
});
};
if (!pid || !req.session.user) {
return RP();
}
if (sz > 10*1024*1024) {
return RP('2');
}
User.watch(req.session.user.name, function(err, user){
if (err) {
OE(err);
return RP('3');
}
if (!user || !user.addprob) {
return RP();
}
fs.readFile(path, function(err, data){
if (err) {
OE(err); //!!!-----throw error here-----!!!
return RP('3');
}
fs.mkdir(data_path+pid, function(){
fs.writeFile(data_path+pid+'/'+fname, String(data).replace(/\r/g, ''), function(err){
if (err) {
OE(err);
return RP('3');
}
return RP();
});
});
});
});
};
The error doesn't always happen.
from multer.
I have same problem. I think file does not exists when route is called.
from multer.
+1. There seems to be some race condition that needs to be addressed.
from multer.
Can you check if v0.1.2 fixed it?
from multer.
@hacksparrow We had this issue and since upgrading from v0.1.0 to v0.1.2 the issue never appeared again. Thanks for all your efforts!
from multer.
Thanks @mperkh. Let's wait for a confirmation from @KIDx and then close it.
from multer.
@hacksparrow thanks for waiting me.
I am not sure and I need more time, if the error appear, I will tell you at once.
Currently, I have some information below:
root@AY1404161244324771c6Z:~/ACdream# cat error.log
2014-07-12 13:13:50 [routes/index.js:1220:7]
Error: ENOENT, open 'uploads/1.cpp'
2014-07-15 23:25:04 [routes/index.js:2059:9]
Error: ENOENT, open 'uploads/d.cpp'
root@AY1404161244324771c6Z:/ACdream# npm ls | grep multer/ACdream# ll node_modules/multer/
├─┬ [email protected]
root@AY1404161244324771c6Z:
total 44
drwxr-xr-x 3 root root 4096 Jul 15 09:16 ./
drwxr-xr-x 20 root root 4096 Jul 15 09:16 ../
-rw-r--r-- 1 root root 5755 Jul 13 22:30 index.js
-rw-r--r-- 1 root root 103 Jul 13 18:38 Makefile
drwxr-xr-x 5 root root 4096 Jul 15 09:16 node_modules/
-rw-r--r-- 1 root root 21 Jul 13 18:38 .npmignore
-rw-r--r-- 1 root root 1512 Jul 15 09:16 package.json
-rw-r--r-- 1 root root 8540 Jul 13 22:22 README.md
from multer.
@KIDx thanks, keep us posted.
from multer.
Multer now has test cases, try to write one to replicate the issue. In the meantime, I am closing this.
from multer.
I'm running into this issue now
from multer.
@afollestad could you please provide some code that exhibits the issue
from multer.
Hi there,
we are experiencing this issue in version 1.3.1. The file upload sometimes works, sometimes fails with this error:
ENOENT: no such file or directory, open '/tmp/uploads/xxx'
This is our code:
const multer = require('multer');
const upload = multer({ dest: '/tmp/uploads' });
FileRouter.post('/files',
Authorization.roles.can('registered'),
upload.array('file'),
FileController.createFiles);
FileController.createFiles:
return Promise
.map(req.files, file => {
return fs.readFileAsync(file.path)
.then(/*...*/);
})
.then(files => res.status(HTTPSTATUS.CREATED).json(files))
// remove temp files
.finally(() => {
return Promise.map(req.files, ({ path }) => {
return fs.unlinkAsync(path).catch(err => log.error(`Failed to delete temp upload file ${path}:\n${err.stack}`));
});
})
.catch(next);
Does anyone have a solution for this?
Thanks,
Jesse
Edit: It tuns out the /tmp/uploads folder didn't exist on all server instances, that's why it sometimes worked and sometimes didn't.
Making sure the folder exists when deploying the server fixed the problem.
mkdir -vp /tmp/uploads/
from multer.
Related Issues (20)
- Why Postman filename is right, but in the web I use formdata.append() the filename is rong? HOT 1
- ERROR UPLOADING FILE
- ERROR UPLOADING FILE using the javascript and I also use multer in handling the fileupload HOT 5
- Translation of Documentation to Indonesian
- Multer gives error on serverless if using without express js
- Error in uploading a photo in javascript using a multer. HOT 2
- There is a way to effectively add a custom Error handler to multer? HOT 2
- (love) Just to tell you how great your software is HOT 1
- TypeError: Cannot read properties of undefined (reading 'length') when fieldNameSize is not set HOT 6
- Upgrade to the latest version of busboy to prevent potential DOS attack via Dicer HOT 1
- File upload got stuck while uploading large text files HOT 3
- Upload file use Multer with Multer-gridfs-storage in environment of bun is not working but when I use environment of nodejs then it's working? HOT 1
- req.file returning Undefined on frontend, but with Insomnia returns correctly HOT 4
- Custom storage engine not working
- MulterError: Unexpected field when trying to use different storage configuration HOT 1
- Update Docs: Error: read ECONNRESET thrown during test using supertest, mocha but works fine while using postman. HOT 1
- Why does Multer does not release memory? HOT 1
- `preservePath` option not respected HOT 2
- This module only works with node 14 or LOWER HOT 39
- file.size undefined with multiple files HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from multer.