我想要接近的是基本的:
忘记客户端,我只是使用邮递员和nodeJS测试这个,所以我只是担心服务器端。
我使用模块abse64-image-upload,所以目前我有这个:
app.post('/upload', function (req, res) {
console.log("HY");
uploader.upload(image, { mime: "image/png", headers: { 'X-Access-Token': '123456789' } }, function (err, response) {
if (!err && response.statusCode == 200) {
console.log(JSON.parse(response.body));
// handle response
} else {
console.log(err, response);
// handle errors
}
});
})
我遇到了与套接字相关的问题:
Error: socket hang up
at TLSSocket.onHangUp (_tls_wrap.js:1124:19)
at TLSSocket.g (events.js:292:16)
at emitNone (events.js:91:20)
at TLSSocket.emit (events.js:185:7)
at endReadableNT (_stream_readable.js:974:12)
at _combinedTickCallback (internal/process/next_tick.js:80:11)
at process._tickCallback (internal/process/next_tick.js:104:9) code: 'ECONNRESET' } undefined
如何在upload方法中收到post方法的代码?