2016-10-08 1 views
0

は、私が画像をアップロードするAPIを開発しているが、いくつかの問題と、それが生成されるという問題がStrongloopは:悪いContent-TypeヘッダをNodejs strongloopを使用

[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

あなたはそれに文字列content-typeを与えましたが、そのバイナリです。 Strongloopはそうすることをサポートしていないかもしれません。 https://github.com/strongloop/loopback-connector-rest/issues/26

このような問題のためにStrongloopを使用しないことをお勧めします。

関連する問題