mirror of
https://github.com/arsvendg/Stirling-PDF.git
synced 2026-07-16 03:20:46 +02:00
Add zip (#3075)
# Description of Changes - Made a recursive function that checks if a file is a zip, then scans its contents. If the content is a zip, or an accepted file type (non-folder, size > 0), add it and repeat the check for zips - Change all convert fragment to accept application/zip - Slightly modified the input file styling to include an ID for appending the "Extracting" text - Added language translation for the "Extracting..." text - (Edit March 3) Removed recursive function, zip file inside target zip file is excluded - For decrypt function after uploading the file, i reused one webworker to handle the decryption , since in the previous code the workers are created but not detroyed for every single file, this caused a huge slow down for uploading large files due to creation of threads and thus this proposal. - Closes #2951 --- ### General - [ ✅] I have read the [Contribution Guidelines](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/CONTRIBUTING.md) - [✅ ] I have read the [Stirling-PDF Developer Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/DeveloperGuide.md) (if applicable) - [✅ ] I have performed a self-review of my own code - [✅ ] My changes generate no new warnings ### UI Changes (if applicable)  Added extracting text (for all language). ### Testing (if applicable) - [ ✅] I have tested my changes locally. Refer to the [Testing Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/DeveloperGuide.md#6-testing) for more details. --------- Co-authored-by: Ludy <[email protected]> Co-authored-by: reecebrowne <[email protected]> Co-authored-by: Reece Browne <[email protected]> Co-authored-by: Anthony Stirling <[email protected]> Co-authored-by: swanemar <[email protected]> Co-authored-by: stirlingbot[bot] <195170888+stirlingbot[bot]@users.noreply.github.com>
This commit is contained in:
co-authored by
Ludy
reecebrowne
Reece Browne
Anthony Stirling
swanemar
stirlingbot[bot] <195170888+stirlingbot[bot]@users.noreply.github.com>
parent
b6b49762f6
commit
b0836d0bd7
@@ -1,5 +1,11 @@
|
||||
export class DecryptFile {
|
||||
|
||||
constructor(){
|
||||
this.decryptWorker = null
|
||||
}
|
||||
|
||||
async decryptFile(file, requiresPassword) {
|
||||
|
||||
try {
|
||||
async function getCsrfToken() {
|
||||
const cookieValue = document.cookie
|
||||
@@ -81,12 +87,23 @@ export class DecryptFile {
|
||||
}
|
||||
|
||||
pdfjsLib.GlobalWorkerOptions.workerSrc = './pdfjs-legacy/pdf.worker.mjs';
|
||||
|
||||
const arrayBuffer = await file.arrayBuffer();
|
||||
const arrayBufferForPdfLib = arrayBuffer.slice(0);
|
||||
var loadingTask;
|
||||
|
||||
const loadingTask = pdfjsLib.getDocument({
|
||||
data: arrayBuffer,
|
||||
});
|
||||
if(this.decryptWorker == null){
|
||||
loadingTask = pdfjsLib.getDocument({
|
||||
data: arrayBuffer,
|
||||
});
|
||||
this.decryptWorker = loadingTask._worker
|
||||
|
||||
}else {
|
||||
loadingTask = pdfjsLib.getDocument({
|
||||
data: arrayBuffer,
|
||||
worker: this.decryptWorker
|
||||
});
|
||||
}
|
||||
|
||||
await loadingTask.promise;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user