How to update zip file with XML content

Viewed 191

Overview

I am using JSZip which allows you to create and update zip files using JavaScript. I would like to update some of the contents of the zip file with other files. However the examples in the documentation only show how to use strings.

In my situation I have an XML file and I want to overwrite another XML file within the Zip file. According to the documentation the file() method supports multiple types:

file(name, data [,options])

String/ArrayBuffer/Uint8Array/Buffer/Blob/Promise/Nodejs stream

Question

I have access to my zip file and my XML file is local as it will be built pro-grammatically. How can I go about using this method to overwrite files with XML files. I also expect the need to overwrite images as well but I also didn't see examples of this either.

Documentation - https://stuk.github.io/jszip/

If I do an import of the XML:

import testXML from '../testXML';

This will not work as when I console log this, I get: static/media/testXML.dd632dc5.xml

Note: I am using React for the frontend if this matters.

0 Answers
Related