使用适配器上传之前,Skipper会调整图像大小

时间:2015-05-12 11:10:05

标签: sails.js graphicsmagick skipper rackspace-cloudfiles pkgcloud

我对this one提出了类似的问题。如何将此上传到我的RackSpace适配器?

以下是代码:

upload: function(req, res){
        var RackspaceAdapter = require('../adapters/rackspace/index'),
            receiver = RackspaceAdapter.receive({
                username: sails.config.rackspace.username,
                apiKey: sails.config.rackspace.apiKey,
                region: sails.config.rackspace.region,
                container: sails.config.rackspace.container
            });
        req.file('file').upload(function (err, uploadedFiles) {
          if (err) return res.send(500, err);
            for(u in uploadedFiles){
                gm(uploadedFiles[u]).resize('500','','^').gravity('Center').crop('500','500').stream().pipe(receiver);
            }
          return res.json({
            message: uploadedFiles.length + ' file(s) uploaded successfully!',
            files: uploadedFiles
          });
        });
    },

0 个答案:

没有答案