jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From test123456 <sajith...@thinkcoretech.com>
Subject Re: Storing and retrieving images from jackrabbit
Date Mon, 04 Jan 2010 04:45:30 GMT

Thank you very much.

I understood the problem. It create a node with the image file name.


On Sun, Jan 3, 2010 at 1:07 PM, vibhu7 [via Jackrabbit] <
ml-node+997613-1385984177@n4.nabble.com<ml-node%2B997613-1385984177@n4.nabble.com>
> wrote:

> Hi,
>
> I think the problem lies in retrieval.
>
> your node addition code creates the following node structure
>
> root <-- attachment <-- 'filename' --- prop-'jcr:data'
>
> when you retrieve you check for
>
> root <-- attachment --- prop-'jcr:data'
>
> Solution:
> fileNode = sourceNode.getNode(<FileName>);
> fileNode.getProperty("jcr:data").getStream();
>
> Hope this solves the problem
>
> regards
> Vibhu
> projectoffguard.com
>
> -
>
> On Fri, Jan 1, 2010 at 4:01 PM, test123456 <[hidden email]<http://n4.nabble.com/user/SendEmail.jtp?type=node&node=997613&i=0>>wrote:
>
>
> >
> > 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.xmlrepository.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.
> >
>
>
> ------------------------------
>  View message @
> http://n4.nabble.com/Storing-and-retrieving-images-from-jackrabbit-tp991766p997613.html
> To unsubscribe from Storing and retrieving images from jackrabbit, click
> here< (link removed) =>.
>
>
>

-- 
View this message in context: http://n4.nabble.com/Storing-and-retrieving-images-from-jackrabbit-tp991766p998057.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message