Yea, definitely don't rely on it being a ByteArrayInputStream. The DelegatingInputStream MIGHT be wrappering a ByteArrayInputStream, but if the attachment is large and we had to stop streaming, it's most likely been spooled to disk (so multi-megabyte attachments don't suck up all the memory) in a temp file so it would be wrappering a FileInputStream. If we're still streaming, it may be the raw HTTP input stream. In anycase, your code doesn't need the BAIS. Just cast it to an InputStream and you should be all set.
Dan On Friday 08 February 2008, Ian Roberts wrote: > Ronald Pieterse wrote: > > and the file is uploaded. I though that if I just copy / paste and > > switch server code to client code and vice versa the download part > > would work too. It does indeed work until I try to do: > > > > bis = (ByteArrayInputStream) file.getData().getContent(); > > > > At that line a ClassCastException is thrown for the > > DelegatingInputStream on which I can find nothing. How do I handle > > this? > > The code you've included doesn't seem to do anything that requires a > ByteArrayInputStream (as opposed to just any old InputStream) so you > could just cast to InputStream, which should work OK. And if you get > something back from getContent() that isn't an InputStream then it > should be safe to call getInputStream on the DataHandler. > > Ian -- J. Daniel Kulp Principal Engineer, IONA [EMAIL PROTECTED] http://www.dankulp.com/blog
