我有一个文件示例,是我从强大的图书馆得到的。看起来像这样
photo: File {
_events: [Object: null prototype] {},
_eventsCount: 0,
_maxListeners: undefined,
size: 16648,
path: 'public/upload_1.jpg',
name: 'test.jpg',
type: 'image/jpeg',
hash: null,
lastModifiedDate: 2021-07-08T11:22:05.804Z,
_writeStream: WriteStream {
_writableState: [WritableState],
writable: false,
_events: [Object: null prototype] {},
_eventsCount: 0,
_maxListeners: undefined,
path: 'public/upload_1.jpg',
fd: null,
flags: 'w',
mode: 438,
start: undefined,
autoClose: true,
pos: undefined,
bytesWritten: 16648,
closed: false
}
}
现在,我需要将此图像传递给一个外部nodejs api,该api希望该图像在
req.file('photo')
格式。
请帮助如何将上述示例发送到nodejsapi。
提前谢谢
1条答案
按热度按时间hjqgdpho1#
serverside formdata和fs.createreadstream对我来说非常有吸引力。