I've got this code:
let file: File = fileList[0];
console.log(file);
var fileReader = new FileReader();
fileReader.onload = (event) => {
this.fileString = fileReader.result as string;
};
fileReader.readAsText(file);
That saves a file's blob as a string. Now I need code that can recover the original blob from the fileString. I'm not seeing any posts that address this already.
Does anyone know how I can recover the original blob?
Currently, I'm trying this code (because the file I'm uploading it a word doc):
var myblob = new Blob([this.fileString], {
type: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
});
console.log(myblob);
saveAs(myblob, "test.docx");
And I'm surprised to see that the original file when console logged is size: 247583 and when I console log in the 2nd section, it's size 433474