1

I am making a web app where a user uploads a local json file, does some calculations based upon user input that get added to the data object within this local file. I then want to be able to save the updates to the exact same file ideally without the user having to select the file (ie uses the same file path as it being uploaded). I am not sure of the best way of doing this or if it is possible at all. The web app is written in Angular and I have also got a Java API I have written that it calls to do certain things. What options are available?

I have had a quick look at the following steps to progress:

  • Try and get the full file path of the uploaded file in the click event when it is uploaded. With this full file name pass it to the Java API to do the save

The code I have used to open the file is:

      this.selectedFile = event.target.files[0];
      const fileReader = new FileReader();
      fileReader.readAsText(this.selectedFile, 'UTF-8"');

There are other actions that are done after it is loaded based upon user input.

However I have had a look at a few other similar problems:

I can appreciate that I might not be able to write a local file direct in Angular due to security issues, but is there another way? Am I going down the best route of using the Java API to write the data back to the file but will have to re-select the file again. What other things should I be looking at?

KitsonRis
  • 23
  • 6

0 Answers0