I have a method for zipping:
(defn zip-project [project-id notebooks files] (with-open [out (ByteArrayOutputStream.) zip (ZipOutputStream. out)] (doseq [nb notebooks] (.putNextEntry zip (ZipEntry. (str "Notebooks/" (:notebook/name nb) ".bkr"))) (let [nb-json (:notebook/contents nb) bytes (.getBytes nb-json)] (.write zip bytes)) (.closeEntry zip)) (doseq [{:keys [name content]} files] (.putNextEntry zip (ZipEntry. (str "Files/" name))) (io/copy content zip) (.closeEntry zip)) (.finish zip) (.toByteArray out)))
after I make the zip, I want to save it to a file, something like /tmp/sample/sample.zip, but I can not do it. that's what I'm doing:
(defn create-file! [path zip] (let [f (io/file path)] (io/make-parents f) (io/copy zip f) true))
The problem is that when I run unzip from the terminal, it says that the zip file is empty, and if I unzip it using the archive utility, it extracts with the extension cpgz.
What am I doing wrong here?
source share