How to upload a zip to firebase storage

Viewed 395

I am trying to upload a zip file that contains an HTML file inside to firebase storage. I am using JSzip to zip the file. Here is how my code looks right now:

 DownloadHandler = () => {
    var zip = new JSZip();
    zip.file("story.html", `<body>${this.state.html}</body>`);
    zip.generateAsync({ type: "blob" }).then(function (blob) {
      storage.ref("story").put(blob);
    });
  };

When I run the current code it uploads the zip but inside the zip, I am getting a document file and not an HTML file. Also, when I click this document file it says it is encoded. How can I modify my code so that when the file zips it zips an HTML file inside?

1 Answers

Figured it out. In my storage.ref("story").put(blob); I just need to specify the extension of the file so it needed to be storage.ref("story.zip").put(blob);

Related