You can get the physical path to the file in a FileDataStore as following 
(note, that this is then Jackrabbit-specific).

(The PhysicalFileInDataStore-class is just a simple POJO)
    public static class PhysicalFileInDataStore {

        private String nodeIdentifier;
        private File file;

        ... (getter und setter)
    }


...
List<Node> fileNodes = getResourceNodes(node);
DataStore ds = ((RepositoryImpl) 
node.getSession().getRepository()).getConfig().getDataStore();
if (ds instanceof FileDataStore) {
    dsPath = new File(((FileDataStore) ds).getPath());
}
for (Node fn : fileNodes) {
    Property prop = fn.getProperty(JcrConstants.JCR_DATA);
    Binary b = prop.getBinary();
    if (b instanceof BLOBInDataStore) {
        if (ds instanceof FileDataStore) {
            PhysicalFileInDataStore pf = new PhysicalFileInDataStore();
            pf.setFile(getFile(getIdentifier(b), dsPath));
            pf.setNodeIdentifier(fn.getIdentifier());
            files.add(pf);
        }
    }
}




    public List<Node> getResourceNodes(final Node node) throws
            RepositoryException {
        List<Node> nodes = new ArrayList<Node>();
        NodeIterator nitg = node.getNodes();
        while (nitg.hasNext()) {
            Node n = (Node) nitg.next();
            if (n.isNodeType(JcrConstants.NT_FILE)) {
                NodeIterator nitFile = n.getNodes();
                while (nitFile.hasNext()) {
                    Node nodeContent = (Node) nitFile.next();
                    if ((JcrConstants.JCR_CONTENT.equals(nodeContent.getName()))
                            && 
(nodeContent.isNodeType(JcrConstants.NT_RESOURCE))) {
                        nodes.add(nodeContent);
                    }
                }
            }
        }
        return nodes;
    }


    public File getFile(DataIdentifier identifier, File directory) {
        String string = identifier.toString();
        File file = directory;
        file = new File(file, string.substring(0, 2));
        file = new File(file, string.substring(2, 4));
        file = new File(file, string.substring(4, 6));
        return new File(file, string);
    }


    public DataIdentifier getIdentifier(Binary binary) {
        if (binary instanceof BLOBFileValue) {
            return ((BLOBFileValue) binary).getDataIdentifier();
        } else {
            return null;
        }
    }

-----Ursprüngliche Nachricht-----
Von: polofan123 [mailto:[email protected]]
Gesendet: Donnerstag, 4. Oktober 2012 16:03
An: [email protected]
Betreff: Avoid binary streaming

In my jackrabbit datastore there are large binary files stored. I can browse 
the datastore filesystem and open these files without any problems.

Now how can I use these files from within my application? I of course could use 
the getStream() method of type jcr.binary but then I would just stream all the 
content of the already exsisting file into a new temporary file right? Since my 
binarys are very large I don't want that. I'm looking for a way to get the full 
filesystem path of a binary. The method getpath() of jcr.Property only returns 
the path within the repository and only with the mapped node names and not the 
node names which are really stored on my filesystem. In general I have to parse 
a binary object into a Java.IO.File object and I want to avoid Streaming




--
View this message in context: 
http://jackrabbit.510166.n4.nabble.com/Avoid-binary-streaming-tp4656705.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.
________________________________

Treffen Sie AEB vom 17.-19. Oktober 2012 auf dem 29. Deutschen 
Logistik-Kongress in Berlin.
Weitere Informationen und Termin-Vereinbarung unter: www.aeb.de/dlk

Reply via email to