Strongloop:Nodejs内容类型标头错误

时间:2016-10-08 20:17:10

标签: node.js upload strongloop

使用strongloop,我开发了一个API来上传图片,但是有一些问题,而且它产生的问题是

[Error: bad content-type header, unknown content-type: image/png]

用于上传的方法我说如下:

post.remoteMethod('testing', {
    description: 'Post a message',
    accepts: [
      {arg: 'contenttype', type: 'String', description: 'eg. image/png', required: true, http: {source: 'query'}},
      {arg: 'ctx', type: 'object', http: {source: 'context'}}
    ],
    returns: {arg: 'success', root: true},
    http: {verb: 'POST', path: '/testing'}
});


post.testing = function (contenttype, ctx, cb) {
        console.log(contenttype , ctx);
            storageProvider.upload(ctx, function (err, response) {
                if (err) throw err;
                Log.e(err, response);
            });

};

1 个答案:

答案 0 :(得分:1)

你给它一个字符串内容类型但它的二进制文件。 Strongloop可能不支持这样做。见https://github.com/strongloop/loopback-connector-rest/issues/26

我建议不要使用Strongloop,因为这样的问题。