jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alexander Klimetschek" <aklim...@day.com>
Subject Re: Jackrabbit examples for File Upload and download
Date Tue, 14 Oct 2008 22:38:41 GMT
Hi,

here is some code snippet, completely plain JCR API, leaving out the
servlet request file uploading part, since this is not part of
Jackrabbit but of your preferred web application framework (you might
want to take a look at Apache Sling [1]). I suggest to read the JCR
spec [2], which is the one-and-only documentation on JCR (and its well
readable for a standard).

------

InputStream fileStream = ... // get the stream from your web app framework
String fileName = ... // get a filename from the request or generate it

Node folder = session.getRootNode().getNode("path/to/file/uploads");
Node file = folder.addNode(fileName, "nt:file");
Node fileContent = file.getNode("jcr:content");
fileContent.setProperty("jcr:data", fileStream);
session.save();

------

[1] http://incubator.apache.org/sling/
[2] http://jcp.org/en/jsr/detail?id=170

Regards,
Alex

On Tue, Oct 14, 2008 at 3:24 PM, Nayak Vishal <VishalN@nsb.no> wrote:
>
> Hello guys,
>
> Does anyone of you have Jackrabbit sample code or examples for File
> Upload and file download.
>
> Regards
> Vishal Nayak
>



-- 
Alexander Klimetschek
alexander.klimetschek@day.com

Mime
View raw message