Unzipping files

前端 未结 8 1680
[愿得一人]
[愿得一人] 2020-11-22 15:54

I want to display OpenOffice files, .odt and .odp at client side using a web browser.

These files are zipped files. Using Ajax, I can get these files from server bu

相关标签:
8条回答
  • 2020-11-22 16:56

    I found jszip quite useful. I've used so far only for reading, but they have create/edit capabilities as well.

    Code wise it looks something like this

    var new_zip = new JSZip();
    new_zip.load(file);
    new_zip.files["doc.xml"].asText() // this give you the text in the file
    

    One thing I noticed is that it seems the file has to be in binary stream format (read using the .readAsArrayBuffer of FileReader(), otherwise I was getting errors saying I might have a corrupt zip file

    Edit: Note from the 2.x to 3.0.0 upgrade guide:

    The load() method and the constructor with data (new JSZip(data)) have been replaced by loadAsync().

    Thanks user2677034

    0 讨论(0)
  • 2020-11-22 16:56

    Code example is given on the author site's. You can use babelfish to translate the texts (Japanese to English).

    As far as I understand Japanese, this zip inflate code is meant to decode ZIP data (streams) not ZIP archive.

    0 讨论(0)
提交回复
热议问题