我写的 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,求大佬给个解决思路,只要说一下需要用的库和大概的思路就行,谢谢了
1
ilaipi 2020-02-12 15:17:52 +08:00 2
|
2
SJ2050cn OP @ilaipi 感谢回复,我想知道在 api 内部发送给其他域名下的 api 接口不就属于跨域了吗,怎么解决这个跨域问题呢
|
4
justin2018 2020-02-12 15:37:43 +08:00 1
|
5
SJ2050cn OP 哦,那我去试试,谢谢
|