【问题标题】:Strongloop: Nodejs bad content-type headerStrongloop:Nodejs 错误的内容类型标头
【发布时间】:2016-10-08 20:17:09
【问题描述】:

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

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

用于上传i的方法如下:

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);
            });

};

【问题讨论】:

    标签: node.js upload strongloop


    【解决方案1】:

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

    由于此类问题,我建议不要使用 Strongloop。

    【讨论】:

      猜你喜欢
      • 2021-12-08
      • 2022-07-20
      • 2020-11-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-07-22
      • 2016-04-17
      • 2017-01-01
      相关资源
      最近更新 更多