You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jackrabbit.apache.org by Dinesh Dani <dr...@gmail.com> on 2010/06/11 03:12:23 UTC
Unable to add the file and file content
Hello,
I am new for jackrabbit and I want to add a file and its content in
node,does anyone can let me know the step by step method(or sample code) to
add a file
Node root = session.getRootNode();
Node forFileNode = root.addNode("testNode");
System.out.println("the value of node is
::::"+forFileNode.getName());
Node resNode = forFileNode.addNode ("jcr:content", "nt:resource");
resNode.setProperty ("jcr:mimeType", "text/plain");
resNode.setProperty ("jcr:encoding", "utf8");
resNode.setProperty("jcr:data", new FileInputStream(f));
session.save();
I am able to create the node and able to see the added node in DAV explorer
but unable to create the file
Thanks in Advance
Re: Unable to add the file and file content
Posted by Alexander Klimetschek <ak...@day.com>.
On Fri, Jun 11, 2010 at 03:12, Dinesh Dani <dr...@gmail.com> wrote:
> Node root = session.getRootNode();
> Node forFileNode = root.addNode("testNode");
The file node should have the "nt:file" node type:
Node forFileNode = root.addNode("testNode", "nt:file");
> System.out.println("the value of node is
> ::::"+forFileNode.getName());
> Node resNode = forFileNode.addNode ("jcr:content", "nt:resource");
> resNode.setProperty ("jcr:mimeType", "text/plain");
> resNode.setProperty ("jcr:encoding", "utf8");
> resNode.setProperty("jcr:data", new FileInputStream(f));
> session.save();
Regards,
Alex
--
Alexander Klimetschek
alexander.klimetschek@day.com