I a I have a file instance which i got from formidable library. It looks like this
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
}
}
Now i need to pass this image to an external nodejs api which is expecting the image in
req.file('photo')
format.
Pls help how to send the above instance to nodejs api.
Thanks in advance
Serverside FormData and fs.createReadStream worked like a charm to me.