 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; index-malformed?
+
+(defn ensure-vector [data]
+  (if (vector? data) data [data]))
+
 (defmulti index-malformed? content-type-from-context)
 
 (defmethod index-malformed? "multipart/form-data" [ctx]
-    (let [file-data (-> ctx :request :multipart-params (get "data"))]
-      (if file-data
-        [false  {::file-data file-data}]
-        true)))
+    (if-let [file-data (some-> ctx :request :multipart-params (get "data") ensure-vector)]
+      [false  {::file-data file-data}]
+      true))
 
 (defmethod index-malformed? :default [ctx]
   (let [request (:request ctx)

    {:dest      :upload
     :type      :measurements
     :entity_id entity_id
     :src-name  "uploads"
     :feed-name "measurements"
     :dir       (.getParent tempfile)

(defmulti index-post! content-type-from-context)

(defmethod index-post! "multipart/form-data" [store pipe ctx]
  (let [file-data    (::file-data ctx)
        session      (-> ctx :request :session)
        username     (sec/session-username session)
        route-params (:route-params (:request ctx))
        entity_id    (:entity_id route-params)
        auth         (sec/current-authentication session)
        items        (template-upload->item file-data entity_id username)
        ;; location     (format uploads-status-resource-path (:user_id auth) uuid)
        ]
    (doseq [item items]
      (pipe/submit-item pipe (assoc item :auth auth)))
    {:response {:status 202
                :headers {"Location" "TBD"} ;; TODO what do we put for location if multiple uploads?
                :body "Accepted"}}))

(defmethod index-post! :default [store pipe ctx]
