admin管理员组文章数量:1399116
I have an application which is a REACT frontend and a python flask backend. The logic is as follows.
- End user uploads a zip file
- Sample zip file structure
source.zip
dontextract
extractfile1
extractfile2
I want to extract extractfile1 and extractfile2 from the zip file and then create a new zip with these two extracted files. Once that is done, I need to send this new zip file to a backend service.
I am finding various solutions on the internet through node packages such as and but these are also suggesting unzipping files in the backend, is there a way to perform this task in the front-end on the REACT side.
I have an application which is a REACT frontend and a python flask backend. The logic is as follows.
- End user uploads a zip file
- Sample zip file structure
source.zip
dontextract
extractfile1
extractfile2
I want to extract extractfile1 and extractfile2 from the zip file and then create a new zip with these two extracted files. Once that is done, I need to send this new zip file to a backend service.
I am finding various solutions on the internet through node packages such as https://www.npmjs./package/unzip and https://www.npmjs./package/unzipper but these are also suggesting unzipping files in the backend, is there a way to perform this task in the front-end on the REACT side.
Share Improve this question asked Aug 13, 2020 at 6:35 Vik GVik G 6494 gold badges9 silver badges25 bronze badges2 Answers
Reset to default 5You can use JSZIP
Example:
const zip = new JSZip();
zip.loadAsync(<YOUR .ZIP FILE>).then(<YOUR FILES IN AN ARRAY>)
My answer is no. You should handle everything related to file (read/write) in server side, not from browser. Like your above two packages, it's used for NodeJS. Not only the problem with browser API to read/write files, it's also the security risk when you let the hacker use Javascript to modify file and send to the server.
本文标签: javascriptUnzipping files in REACT and then rezipping it againStack Overflow
版权声明:本文标题:javascript - Unzipping files in REACT and then rezipping it again - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744175531a2593980.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论