At Fri, 20 May 2011 09:59:35 -0400,
Ken Wesson wrote:
> 
> On Fri, May 20, 2011 at 9:22 AM, Vincent Liard <vincent.li...@free.fr> wrote:
> > (defn retailer-stock-update []
> >  (wrap-multipart-params
> >   (fn [req]
> >     (let [xls (get (:params req) "stock-xls")]
> >       (with-in-str [str (:bytes xls)]
> >         (read-xls-stream str))))))
> >
> > As far as I have understood, (:bytes xls) is seen as a java byte
> > array, since (class (:bytes xls)) displays "class [B"
> 
> That is correct. So try replacing the last two lines with:
> 
> (with-open [str (ByteArrayInputStream. (:bytes xls))]
>   (read-xls-stream str))
> 
> The exception is because with-in-str is expecting a single string
> argument, not a binding vector; with-in-str temporarily rebinds *in*
> to read from a string rather than binding an arbitrary stream.

Thank you! I eventually noticed my error on the with-in-str call, but
I would never have found ByteArrayInputStream. The clojure newcomer
should be ready to learn java :) Many thanks for your help!

Vincent

-- 
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

Reply via email to