Thanks for the feedback Jarrod, the gallery-path did exist because I was 
able to upload files without renaming them and I saw the map with keys per 
your tip. I just wasn't familiar enough with the plumbing in noir.io or the 
language as I finally had the time to spend a week getting into clojure 
more seriously. Took a look in more depth in noir.io, surprisingly concise 
and simple to understand. With some much appreciated help finally got it 
working as follows:

(ns pgapp.routes.upload 
  (:require [compojure.core :refer [defroutes GET POST]]
            [pgapp.views.layout :as layout]
            [noir.io :refer [upload-file resource-path]]
            [noir.session :as session]
            [noir.response :as resp]
            [noir.util.route :refer [restricted]]
            [ring.util.response :refer [file-response]]
            [taoensso.timbre :refer [error]]
            [pgapp.models.db :as db]
            [clj-time.core :as time]
            [clj-time.coerce :as tc]
            [pgapp.util
            :refer [galleries gallery-path thumb-uri thumb-prefix 
unique-prefix]]))

(defn upload-page [info]  
  (layout/render "upload.html"))

(defn add-timestamp [filename]
 (let [ext-position (.lastIndexOf filename ".")
       timestamp    (tc/to-long (time/now))]
   (if (pos? ext-position)
     (str (.substring filename 0 ext-position)
          "-" timestamp (.substring filename ext-position))
     (str filename "-" timestamp))))

(defn handle-upload [file]
  (upload-file (gallery-path) (update-in file [:filename] add-timestamp))
  (resp/redirect "/upload"))

(defroutes upload-routes
  (GET "/upload" [info] (upload-page {:info info}))
  (POST "/upload" [file] (handle-upload file)))


The key to it was the 2nd line in handle-upload as:

(upload-file (gallery-path) (update-in file [:filename] add-timestamp))

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to