Coding problems of uploading and downloading JS files

my requirement is : for a large file of any type (text / picture or audio / video file), after the user chooses to upload, the large file is multipart and uploaded (specifically implemented by file.silce), and then downloaded through URL.createObjectURL (blob).

the problem now is : how to use a general FileReader function to read content, so that any type of file uploaded through the program and then downloaded, the file is still intact.

some current attempts:
1. For a document of text type, if the content contains Chinese, upload it in the following way,

  filder[curindex] = new FileReader();
                                filder[curindex].readAsText(file.slice(start, end),"gb2312");

                                filder[curindex].onload = function () {
                                    tempcell.n = curindex;
                                    tempcell.data = filder[curindex].result;
                                    console.log(tempcell)
                                    //chunk
                                    uploading("chunks", tempcell, chunksurl);
                                }

when downloading, the file code is not garbled.
2. For the picture type of the use of readAsDataURL to convert the picture data into base64, and then download the file can not be opened, prompting the format error, but directly with img src= "above base64" can be displayed on the web page, should be to carry out base64 decoding can be displayed locally.

now the main question is whether there is a unified API function for general file processing, so that after uploading and downloading, the file format is still correct. Thank you. There is nothing special about the download section, which is to use the traditional create a tag and make use of its download attribute. The complete code address of the
page:
https://github.com/guangying1.

Mar.01,2021
Menu