I am trying to convert Blob to a File object in nodejs. The Blob is passed from my frontend to my backend. I then want to convert it in my backend.
Here is my current code:
frontend
var data = {
"file": file, //this is blob
"file_name": bucket_string
};
return await axios.post(`/files/upload-file`, data);
backend
const file = new File(data['file'], "tests/" + customer + "/" + sound + ".wav");
Currently this throws an error:
ReferenceError: File is not defined
How can I properly convert the data in nodejs?
I don't have enough reputation to comment so sorry that this is a full post. File is an interface in TypeScript but does not specifically exist with node.js (sans TypeScript). I don't see anything referencing TypeScript in your code so maybe it's because you're not using typescript. For information on the File interface reference the docs here. Without knowing if you're using typescript I'm not sure what more to say about the File interface.