Hey guys,
I am developing a web application using Noir and CouchDB. I store some attachments (images) in my documents on CouchDB. There is a form on my site with a file input that users can use to put images in the database, and that works well (I am using Asafa- Clutch by the way).
I want to have a page on the site where I can display their images that they have uploaded. So, to get the attachment back, I call (clutch/get-attachment db document filename) and I receive an HTTPInputStream. In clutch he mentions that I can use
clojure.contrib.io/to-byte-array to convert this to a byte array. I am new to Noir, and my question is, how I can take either the input stream or byte array of the image and have the image displayed on a page?
I am thinking something like:
(defpage "/:user/getphoto" {:keys [user] :as m}
;;shared/page is a function that uses a 'deftemplate'
;;user/get-photo returns an HTTPInputStream of the photo from the db
(shared/page {:main (content (user/get-photo user "main photo 2"))
:active-section "Photos"
:sources ["/cljs/bootstrap-tab.js"]})
)
The above of course doesnt work, because content cant take an HTTPInputStream.
Any ideas how I should do this?
Thanks
-David