Hi, thanks for for quick answer! I already played around with
ResourceStreams, but my problem was that I couldn't do the bridge from a
Stream to a Resource with a URL.

I should add, I'm not offering my ByteArrayResources as a download. I pass
the content-type and filename, and (with the help I got from a user here)
return it as INLINE. So, when the user clicks, the browser opens the
filetype if it can (e.g. a picture, or a PDF with a built-in viewer).

Also (and that's important) I then have a real URL which I can pass to
Javascript functions. E.g. if the attachment is an mp3 or a video, I
additionally use the URL of the ResourceLink to open a custom flash-player
(JW Player).. I need a solid URL for that, for that session.

When I played around I just couldn't manage to get that kind of URL when I
worked with Streams. But I will give it another try.

PS: I found this example a while ago, and wanted to implement my own
IResourceStream to fetch the attachments from the DB, but the example is
outdated and I couldn't figure out how to do it with a newer version of
Wicket: http://goo.gl/imGrl

2012/8/16 Sven Meier <s...@meiers.net>

> Take a look at DownloadLink and FileResourceStream, and replace all File
> related API to your CouchDB access.
>
> Sven
>
> Michael M <generi...@gmail.com> schrieb:
>
> >Hi, in my project I use a CouchDB with files as attachments. Currently I
> >have a page that makes those attachments available via a ResourceLink.
> What
> >I do when creating that page is:
> >
> >   - I read all attachments (I get them as an InputStream),
> >   - create a byte[] out of it,
> >   - create a static Wicket ByteArrayResource
> >   - and put the link to that resource on the page.
> >
> >That works for smaller files, but a huge problem is of course: it's
> static,
> >and I get memory problems if the attachments get too big. Also, currently
> >obviously each session does this.
> >
> >What I would like to do instead is:
> >
> >   - create Resources that will load my attachments dynamically if the
> link
> >   is clicked,
> >   - and add ResourceLinks to those resources on my page instead.
> >   - If possible, maybe deliver the attachments directly from the
> >   InputStream my CouchDB delivers, so I don't have to have any static
> >   byte-arrays on my server.
> >
> >That way I could make the page load immediately and deliver attachments
> >only if required.
> >
> >I've wrapped my head around IResourceStreams, but I just can't see clear
> >anymore and am confused about how to create those dynamic resources (also
> >because some old examples don't work anymore with Wicket 1.5 or 6beta3).
> >
> >I'd be very thankful for a short example, or a hint about how to design
> >this. Thank you!
>

Reply via email to