Open Shedal opened 11 years ago
Hi Dimini,
Would you mind sending my the output from an npm ls fineuploader-express-middleware
and npm ls formidable
?
Many thanks Andrew
Hi, thanks for quick reply. Here's the output:
$ npm ls fineuploader-express-middleware
goapp@0.0.1 /var/lib/stickshift/2a92c6b52c0840199612fba80ffa2314/app-root/data/278055
└── fineuploader-express-middleware@0.0.1
$ npm ls formidable
goapp@0.0.1 /var/lib/stickshift/2a92c6b52c0840199612fba80ffa2314/app-root/data/278055
├─┬ connect@2.7.0
│ └── formidable@1.0.11
├─┬ express@3.0.3
│ └─┬ connect@2.7.0
│ └── formidable@1.0.11
└─┬ fineuploader-express-middleware@0.0.1
└── formidable@1.0.11
So both packages are of the latest version. The real problem is, formidable hasn't been updated in npm for the past 6 months. Octet stream support for formidable is on GitHub, but not yet in npm. I've no idea why they are not keeping the npm package up-to-date. I guess it worked for you, because you downloaded node-formidable straight from GitHub.
Hi Dmytro,
Indeed, it looks like that is why its working for me: I've got the following in my package.json:
"formidable": "git://github.com/felixge/node-formidable.git",
And since I had installed that first and it's retaining the same version number, it was used instead of downloading the packaged one. As a stop-gap for the moment, you could do the same, but I will try see if I can get some idea of why no releases have been done on node-formidable or possible incorporate the required change into this module until a new release of formidable appears.
Hi Andrew,
Thanks for the suggestion. Though, I don't like to use unstable (i.e. non-npm) versions, even during development. For now, I've implemented my own simple middleware that does not use node-formidable. It's not full-featured, but it does what I need. In case you're interested:
var fs = require('fs');
var uuid = require('node-uuid');
var path = require('path');
exports = module.exports = function(options) {
options = options || {};
var uploadDir = options.uploadDir || '/tmp';
return function(req, res, next) {
if(req.xhr && req.header('x-file-name')) {
//
// Handle direct async XHR stream data upload.
var extension = path.extname(req.header('x-file-name'));
var filename = uuid.v4() + extension;
var tmpFilePath = path.join(uploadDir, filename);
var ws = fs.createWriteStream(tmpFilePath);
ws.on('close', function(err) {
req.files['fineUpload'] = {
path: tmpFilePath,
name: filename,
type: req.header('x-mime-type')
};
next();
});
req.pipe(ws);
} else {
next();
}
};
};
Shedal,
That works great! Any chance you will make this a module in NPM?
I'm getting this error:
I am using the latest versions of all packages, including formidable.