问题
I'm using the following code to read data from local storage on the client side:
fileChange(event)
{
let file = event.target.files[0];
var reader = new FileReader();
reader.readAsText (file);
reader.onload = () => {
console.log (reader.result);
}
let fileSaverService = new FileSaverService;
var blob = new Blob(["Hello, world!"], {type: "text/plain;charset=utf-8"});
fileSaverService.save (file, "hello.txt");
The contents in 'file' is saved to "hello.txt" This is not what I need. I want to modify the contents of the selected file (event.target.files[0]).
Thank you in advance, Zvika
来源:https://stackoverflow.com/questions/59162408/angular-8-read-from-local-storage-modify-and-save-back-to-same-file