Skip to content

Instantly share code, notes, and snippets.

@jraines
Created May 5, 2016 18:30
Show Gist options
  • Save jraines/65e2628b699abf759da78e5d265d0d0f to your computer and use it in GitHub Desktop.
Save jraines/65e2628b699abf759da78e5d265d0d0f to your computer and use it in GitHub Desktop.
(defn process-image-file
[file]
(let [filename (.getName file)]
(when-let [item (find-by-image-filename-no-path filename)]
(let [f (ZipFile. (io/file "/tmp/what"))]
(io/copy (.getInputStream f file)
(io/file "resources" "tmp" (str (:id item) "-" filename)))))))
(defn- entries [zipstream]
(lazy-seq
(if-let [entry (.getNextEntry zipstream)]
(cons entry (entries zipstream)))))
(defn walkzip [file]
(with-open [z (ZipInputStream. (io/input-stream file))]
(doseq [e (entries z)]
(process-image-file e))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment