我正在使用SailsJS(测试版).我试图找到一种方法来使用graphicsmagick在SailsJS-beta中使用Skipper解析的流来调整Skipper函数之前调整图像大小req.file('inputName').upload().
我的目标是拍摄我原始的大图像,并在上传之前调整大小.Sails beta引入了Skipper文件解析器,这些解析器文档很少(至少我不理解它).请帮我了解如何在上传前调整图片大小.
这工作(我的控制器动作中的代码):
req.file('fileName').upload('storedImage.png', function(err, files){
// File is now uploaded to storedImage.png
});
Run Code Online (Sandbox Code Playgroud)
我想要的是:
// Read the file stream into a file upload
var stream = req.file('fileName');
gm(stream).resize(200, 200).write('storedImage.png', function(err){
// File is now resized to 200x200 px and uploaded to storedImage.png
});
Run Code Online (Sandbox Code Playgroud)
我的问题是:如何正确获取流req.file('fileName')以将其发送到gm?