   "It creates tmpdir and add it to request data"
   [[metadata payload]]
   (let [tmpdir (fs/temp-dir "test-export-to-kramerius-request-")]
-    [[metadata payload] tmpdir]
-    )
-  )
+    [[metadata payload] tmpdir]))
 
 (defn save-request
   "it returns name of a directory where payload is saved"
   [[[metadata payload] workdir]]
   (def msg (json/read-str (String. payload) :key-fn keyword))
   (def marcxml-file (io/file workdir "oai_marc.xml"))
-  (def data-file (->> (:filename msg)
-                     io/file
-                     .getName
-                     (io/file workdir)
-                     )
-    )
 
   (log/info "save export request to" workdir)  
   (spit (-> marcxml-file .toString (.concat ".b64")) (:b64_marcxml msg))
-  (spit (-> data-file .toString (.concat ".b64")) (:b64_data msg))
   (spit (io/file workdir "uuid") (:uuid msg))
-  (spit (io/file workdir "filename") (:filename  msg))
+  (spit (io/file workdir "urnnbn") (:urnnbn msg))
 
   (with-open [out (io/output-stream marcxml-file)]
     (.write out (Base64/decodeBase64 (:b64_marcxml msg))))
-  (with-open [out (io/output-stream data-file)]
-    (.write out (Base64/decodeBase64 (:b64_data msg))))
 
-  workdir
-  )
+  (let [out-dir (io/file workdir "img_full")
+        data (-> msg :img_full)
+        ]
+    (.mkdir out-dir)
+    (spit (io/file out-dir "mimetype") (-> data :mimetype))
+    (spit (io/file out-dir "filename") (-> data :filename))
+    (with-open [out (io/output-stream (io/file out-dir (-> data :filename)))]
+      (.write out (Base64/decodeBase64 (-> data :b64_data)))))
+
+  (let [out-dir (io/file workdir "img_preview")
+        data (-> msg :img_preview)]
+    (.mkdir out-dir)
+    (spit (io/file out-dir "mimetype") (-> data :mimetype))
+    (spit (io/file out-dir "filename") (-> data :filename))
+    (with-open [out (io/output-stream (io/file out-dir (-> data :filename)))]
+      (.write out (Base64/decodeBase64 (-> data :b64_data)))))
+
+  workdir)
 
 (defn prepare-marcxml2mods-request
   [workdir]



(defn make-foxml
  [[mods workdir] [oai_dcs workdir-1]]
  {:pre [(= workdir workdir-1)]}
  (let [uuid (slurp (io/file workdir "uuid"))
        foxml-dir (io/file workdir uuid)
        ]
    (.mkdir foxml-dir)
    (let [foxml (f/foxml mods oai_dcs 
                         {:uuid uuid :label "ahoj" 
                          :created (t/now)
                          :last-modified (t/now)
                          })
          out-file (io/file workdir uuid (str uuid ".xml"))
          ]
      ;(pp/pprint foxml)
      (with-open [out (io/writer out-file)]
        (xml/emit foxml out))
      [uuid workdir]
      )
    )
  )

(defn parse-and-export [metadata ^bytes payload]
  (let [msg (json/read-str (String. payload) :key-fn keyword) 

  [{:uuid (.toString workdir)}
   {:marc_xml (slurp (io/file workdir "oai_marc.xml"))
    :uuid (slurp (io/file workdir "uuid"))
    }])

(defn save-marcxml2mods-response
  [[metadata payload]]
