   [conn {:keys [id user file collection]}]
   (let [id (or id (uuid/v4))
         filename (.getFileName ^UploadedFile file)
-        ext (FilenameUtils/getExtension oname)
-        path @(st/save (str id "." ext) file)
+        ext (FilenameUtils/getExtension filename)
+        path @(st/save md/storage (str id "." ext) file)
         sqlv (sql/create-image {:id id
                                 :path path
                                 :collection collection
                                 :user user})]
     (some-> (sc/fetch-one conn sqlv)
-            (usc/normalize-attrs))))
+            (data/normalize-attrs))))
 
-(def ^:private create-image-schema
+(def create-image-schema
   {:id [us/uuid]
    :user [us/required us/uuid]
    :file [us/required us/uploaded-file]})

                                           :user user
                                           :name name})]
    (-> (sc/fetch-one conn sqlv)
        (usc/normalize-attrs))))

(def ^:private create-collection-scheme
  {:id [us/uuid]
   :user [us/required us/uuid]
   :name [us/required us/string]})

  (:require [suricatta.core :as sc]
            [clj-uuid :as uuid]
            [buddy.core.codecs :as codecs]
            [storages.core :as st]
            [uxbox.config :as ucfg]
            [uxbox.schema :as us]
            [uxbox.media :as md]
            [uxbox.sql :as sql]
            [uxbox.util.transit :as t]
            [uxbox.services.core :as usc]
            [uxbox.util.data :as data])
  (:import ratpack.form.UploadedFile
           org.apache.commons.io.FilenameUtils))

