Long story short, I used a DataForm object that contains a blob of an image as one of the parts and sent it to my node.js server into the formidable parser:
//blob enters the files variable
formParser.parse(req, (err, fields, files)=>{
if(err)throw err;
const fileInfo = JSON.parse(fields.JSON);
//figure out how to read the blob, how to get it's array buffer, then write to C disk
console.log(files);
//fs.writeFile() here
})
How do I extract the Blobs ArrayBuffer from this persistent file in formidable that looks like this:
{
Binary: PersistentFile {
_events: [Object: null prototype] { error: [Function (anonymous)] },
_eventsCount: 1,
_maxListeners: undefined,
lastModifiedDate: 2022-06-15T17:44:50.214Z,
filepath: 'C:\\Users\\rnata\\AppData\\Local\\Temp\\f962bfe8ab505addfba1e4600',
newFilename: 'f962bfe8ab505addfba1e4600',
originalFilename: 'blob',
mimetype: 'image/png, image/jpg, image/jpeg',
hashAlgorithm: false,
size: 373021,
_writeStream: WriteStream {
_writableState: [WritableState],
_events: [Object: null prototype],
_eventsCount: 1,
_maxListeners: undefined,
path: 'C:\\Users\\rnata\\AppData\\Local\\Temp\\f962bfe8ab505addfba1e4600',
fd: 4,
flags: 'w',
mode: 438,
start: undefined,
autoClose: true,
pos: undefined,
bytesWritten: 373021,
closed: false,
[Symbol(kFs)]: [Object],
[Symbol(kCapture)]: false,
[Symbol(kIsPerformingIO)]: false
},
hash: null,
[Symbol(kCapture)]: false
}
}
What classes do I need, or what methods do I have to use, so that I can extract an arraybuffer and use it in fs.writeFile().
Thank you!