Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

There is something wrong with the file saved in firefox. #334

Open
haoma2514 opened this issue Nov 28, 2023 · 0 comments
Open

There is something wrong with the file saved in firefox. #334

haoma2514 opened this issue Nov 28, 2023 · 0 comments

Comments

@haoma2514
Copy link

haoma2514 commented Nov 28, 2023

The zip file saved by firefox is incomplete.
The following are files saved by Firefox:
图片
The file saved by chrome is correct.
图片

this's my code:

export const downloadFileByFetchToZip = (fileName:string,files:downloadAnnexModel[])=>{   
    streamSaver.mitm= '/shtml/mitm.html'    
    const zipFileOutputStream = streamSaver.createWriteStream(fileName+".zip");      
    const fileIterator = files.values();  
    const readableZipStream = new Zip({  
        async pull(ctrl) {  
            const fileInfo = fileIterator.next();  
            if (fileInfo.done) { 
                ctrl.close();  
            } else {  
                const {fileName, fileUrl} = fileInfo.value;  
                return fetch(fileUrl).then(res => {  
                    ctrl.enqueue({  
                        fileName,  
                        stream: () => res.body  
                    });  
                }).catch((x)=>console.error("error",x))  
            }      
            //ctrl.close()   
        }    
    });  
    if (window.WritableStream && readableZipStream.pipeTo) {  
        readableZipStream  
            .pipeTo(zipFileOutputStream)  
            .then(() => console.log("done")).catch((error)=>{
                console.log("error",error)
            })  
    }  
}

After the file is saved, the then block is not executed, and the catch block is not executed. It is not clear which link has gone wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant