I'm working on an application where users can upload zip files which are always password protected. I have a file-uploader, and a simple text-input for that password.
Currently, the password is only checked in the BE after the file upload (which might take several minutes, since the files can be several GB) and when the password is incorrect, the user will get an application message (not really important how that works) saying 'upload failed, provided wrong password' and they have to start the entire process from scratch.
I want to make it so that the upload process won't even start when the provided password is incorrect. So; how do i only verify the password of a zip file in Angular(9) without extracting that entire file?
hello on StackOverflow!
I would say it is not easily doable to check the validity of the password beforehand, but some projects exist that may help you.
The Reason is that browsers do not have access to a filesystem yet. (The Native Filesystem API is currently in chrome origin trial, check here for more information and future updates on browser compatibility)
You could try to use an in-memory filesystem in the browser as a replacement, for example memfs in combination with memfs-webpack.
But keep in mind:
I found this page, which seems to be a zip extract in pure JavaScript in the Browser: https://zipextractor.app/
They claim to not send the files to any server for extraction, so you may be able to find the tools there you need to implement that functionality for yourself.
I hope this was helpful!
Benjamin