var multiparty = require('multiparty'); var thumb = require('node-thumbnail').thumb;
router.post('/thumbnail',function(req,res){ console.log("썸네일 변경!"); var form = new multiparty.Form(); form.parse(req,function(err,fields, files){ if(err){ console.log(err); } Object.keys(fields).forEach(function(name) { console.log('got field named ' + name); }); console.log("files:", files);
var fileName=fields.fileName[0]; var oldPath = files.imageFile[0].path; console.log(fileName); // 서버에서 돌리는 부분 var newPath = '/root/imageServer/public/images'; thumb({ basename:fileName.split(".")[0], suffix:'', source: oldPath, destination: newPath, width: 300 }).then(function() { console.log('Success'); res.sendStatus(200) }).catch(function(e) { console.log('Error', e.toString()); res.sendStatus(500); });
}) })
default options
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
defaults = { prefix: '', suffix: '_thumb', digest: false, hashingType: 'sha1', // 'sha1', 'md5', 'sha256', 'sha512' width: 800, concurrency: <num of cpus>, quiet: false, // if set to 'true', console.log status messages will be supressed overwrite: false, basename: undefined, // basename of the thumbnail. If unset, the name of the source file is used as basename. ignore: false, // Ignore unsupported files in "dest" logger: function(message) { console.log(message); } };
Comments