我正在尝试对使用formidable上传的文件使用compress_images模块,但出现“文件不存在”的错误。任何想法为什么?这是来自 routes.js 的代码:
app.post('/uploadPicture', isLoggedIn, function(req, res) {
const form = formidable({ multiples: true });
form.parse(req, (err, fields, files) => {
if (err) {
next(err);
return;
}
compress_images(URL+files.someExpressFiles.path+"/"+files.someExpressFiles.name
, "public/build"+files.someExpressFiles.path+"/",
{compress_force: false, statistic: true, autoupdate: true}, false,
{jpg: {engine: 'mozjpeg', command: ['-quality', '60']}},
{png: {engine: 'pngquant', command: ['--quality=20-50']}},
{svg: {engine: 'svgo', command: '--multipass'}},
{gif: {engine: 'gifsicle', command: ['--colors', '64', '--use-col=web']}}
, function(error, completed, statistic){
console.log('-------------');
console.log(error);
console.log(completed);
res.json(statistic);
console.log('-------------');
});
res.json({ fields, files });
});
});
蓝山帝景
相关分类