Hi Moritz and Michael, thanks for the pointer in the right direction.
Almost there except for 1 point I think. The whole operation is made of 2
functions, one to upload/resize/save and the other to provide a unique
filename by original filename + timestamp.
(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 update-profile2 [firstname lastname email file]
(let [member-id (session/get :member-id)
redirecturl (str "/member/" member-id)
originalfile (str (img-path) "/" (:filename file))
new-file-name (add-timestamp (:filename file))
photofile (str (img-path) "/" new-file-name)]
(upload-file (img-path) *(update-in file [:filename] new-file-name))*
(resize (file (with-open [rdr (clojure.java.io/reader photofile)])) 100
100)
(memberdb/update-member member-id firstname lastname email (str
new-file-name))
(resp/redirect redirecturl)))
I checked output of new-file-name and photofile, they do provide the new
file name alone or with full path.
Where I'm still goofing up is applying new-file-name to the update-in
function, prob cause its 6am :) Been at it too long, likely missing the
obvious.
If I can update the filename to *new-file-name*, the *with-open reader *should
read the file so it can be resized.
Pardeep.
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.