Hi new to jackrabbit.
I try to create a content repository to store the images uploaded by users
from my web application.
I am having the environment
Tomcat 6.0.13 server
JDK 1.6
Jackrabbit 1.6
I am using the following code snippet for that for adding image
Node rootNode = session.getRootNode();
String fileName = "abc.gif";
String destinationNodeName = "attachment";
// First check the type of the file to add
MimeTable mt = MimeTable.getDefaultTable();
String mimeType = mt.getContentTypeFor(fileName);
if (mimeType == null)
{
mimeType = "application/octet-stream";
}
// Get the destinationNode to which the file to be added
Node destinationNode =
rootNode.addNode(destinationNodeName);
Node file = destinationNode.addNode(fileName,
"nt:file");
Node contentNode = file.addNode("jcr:content",
"nt:resource");
// Make a stream object using the file path
InputStream fileStream = new FileInputStream(filePath);
// set the mandatory properties
contentNode.setProperty("jcr:data", fileStream);
contentNode.setProperty("jcr:lastModified",
Calendar.getInstance());
contentNode.setProperty("jcr:mimeType", mimeType);
session.save();
System.out.println("File "+ fileName + "added to the
Node "+
destinationNodeName + " in the repository");
It is printing the message "File abc.gif added to the
Node attachment in
the repository" in the console.
I used the following code snippet for diaplying image in jsp page
Node rootNode = session.getRootNode();
Striing sourceNodeName = "attachment";
Node sourceNode = rootNode.getNode(sourceNodeName);
if(sourceNode != null)
{
fileStream =
sourceNode.getProperty("jcr:data").getStream(); // throws
javax.jcr.PathNotFoundException: jcr:data in this line
}
What will be reason for the exception.
I am attached my repository.xml
http://n4.nabble.com/file/n991766/repository.xml
repository.xml
http://n4.nabble.com/file/n991766/repository.xml repository.xml
--
View this message in context:
http://n4.nabble.com/Storing-and-retrieving-images-from-jackrabbit-tp991766p991766.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.