保存图像并将其调整为Cloudinary,而不将图像保存在磁盘上

时间:2015-03-24 10:48:17

标签: node.js azure cloudinary

如何使用mutiparty直接调整多个图像的大小并将流发送到Cloudinary

router.post('/', function(req, res){
    var form = new multiparty.Form();

    form.on('part', function(part) {
       // Stream it to Cloudinary without saving it to disk
    }
}

我这样做是因为我在Azure网站上托管,无法将图像保存在临时文件夹中。

1 个答案:

答案 0 :(得分:0)

我不确定你可以尝试:

var cloudinary = require('cloudinary'); //npm install cloudinary
cloudinary.config({/*your config object*/});
var request = require('request'); //npm install request

router.post('/', function(req, res){
    var form = new multiparty.Form();

    form.on('part', function(part) {
        if (part.filename) {
            var url = cloudinary.url(part.filename, {type: 'fetch'/*, width: 256*/});
            request.head(url, function (err, res, body) {
                //...
            });
        }
    }
}