Context
- node version: v10.10.0
- module (formidable) version: 1.2.1
What are you trying to achieve or the steps to reproduce?
I'd like to use the option hash to rename my file using the a sha1 string.
form = formidable.IncomingForm({
hash: 'sha1'
});
form.on('fileBegin', function(name, file) {
if (file.name !== '') {
var ext = file.name.match(/\.(jpg|jpeg|png|pdf)$/i)[0];
file.path = './public/uploads/' + file.hash + ext;
}
});
form.on('file', function(name, file) {
var resizeImageOptions;
if (file.name !== '') {
resizeImageOptions = _.find(fileFields, { field: name }).resizeImageOptions;
if (file.name.match(/.jpeg|.jpg|.png|.gif/g)) {
if (resizeImageOptions) {
ImageHelper.resize(file, resizeImageOptions.imageWidth || 0, resizeImageOptions.imageHeight || 0, resizeImageOptions.forceResize || false);
} else {
ImageHelper.resize(file, 500, 500, true);
}
}
}
});
form.parse(request, function(err, fields, files) {
var item = _.clone(fields);
// here I save the data in my database
});
What was the result you got?
The file is rename by [Object object].png.
What result did you expect?
The name of the geenrated sha1 string with the correct extension.
Context
What are you trying to achieve or the steps to reproduce?
I'd like to use the option
hashto rename my file using the asha1string.What was the result you got?
The file is rename by
[Object object].png.What result did you expect?
The name of the geenrated
sha1string with the correct extension.