我写的 nodejs 接口是基于 koa 框架的,并使用 koa-better-body 将上传的文件解析,解析得到的文件数据如下:
File {
_events: [Object: null prototype] {},
_eventsCount: 0,
_maxListeners: undefined,
size: 297525,
path: '/tmp/upload_0be4ede06f899420d94441f9d64ff49d',
name: 'AIRBUS_HoF_2018_Screenshot1.jpeg',
type: 'image/jpeg',
hash: null,
lastModifiedDate: 2020-02-12T06:32:46.177Z,
_writeStream: WriteStream {
_writableState: WritableState {
objectMode: false,
highWaterMark: 16384,
finalCalled: true,
needDrain: false,
ending: true,
ended: true,
finished: true,
destroyed: true,
decodeStrings: true,
defaultEncoding: 'utf8',
length: 0,
writing: false,
corked: 0,
sync: false,
bufferProcessing: false,
onwrite: [Function: bound onwrite],
writecb: null,
writelen: 0,
bufferedRequest: null,
lastBufferedRequest: null,
pendingcb: 0,
prefinished: true,
errorEmitted: false,
emitClose: false,
autoDestroy: false,
bufferedRequestCount: 0,
corkedRequestsFree: [Object]
},
writable: false,
_events: [Object: null prototype] {},
_eventsCount: 0,
_maxListeners: undefined,
path: '/tmp/upload_0be4ede06f899420d94441f9d64ff49d',
fd: null,
flags: 'w',
mode: 438,
start: undefined,
autoClose: true,
pos: undefined,
bytesWritten: 297525,
closed: true
}
}
然后如何将图片转发给另一个 api 接口呢(我是打算把图片上传至图床 api ),有没有办法将发送来的 file 数据流直接发个另一个 api,求大佬给个解决思路,只要说一下需要用的库和大概的思路就行,谢谢了
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.