2 years ago

#59107

test-img

Avner Moshkovitz

Is it possible to re-open a file that was selected via the "input file" button programatically

In my web app the user selects a large zip file via an "input file" button.
The file is then returned as a blob (see the snapshot zipfile1).
The program then reads chunks (individual files) of the zip file one after the other.
A test program reads through all the files in a sequence, and then repeats the sequence multiple times.
This works ok on various OSs (Windows Linux, MacOs, Android) via various browsers (Chrome, Firefox, Safari).
But on iOS sometimes the blob object is lost, and the process returns an error.
In such case I can select the file again to continue the process.

But I would like to do this programatically, without the need for manual intervention.
I still have the filename, but the blob size is 0 (see the snapshot zipfile2).

Is it possible to re-open the file programatically?
Thanks


EDIT:

I tried to call

let zipFileUrl = URL.createObjectURL(zipFile);

to have some kind of a "handle" to the file in memory without the actual data.
The idea was that later on, if the file object gets corrupt, I can fetch(zipFileUrl) to reopen the file.
Unfortunately, createObjectURL creates a memory blob from the entire file in memory, which is useless to me because the file is too big...


zipFile1 zipfile1

zipfile2 zipFile2

javascript

fileapi

0 Answers

Your Answer

Accepted video resources