Can you read the other non-binary properties? Do you do a session save? Do you seen any errors in the log? What is your repository / persistence manager configuration?
Cheers, Alex On 22.04.2013, at 18:05, garihood <[email protected]> wrote: > Thanks for the reply. > > I've created an InputStream variable: > InputStream input = new FileInputStream(file); > > and replaced my old code: > resNode.setProperty("jcr:data", new FileInputStream(file)); > > with your suggestion: > resNode.setProperty(JcrConstants.JCR_DATA, > > resNode.getSession().getValueFactory().createBinary(input)); > > Unfortunately, the files I try to extract remain 0 bytes long. > > > > This is the current importFile() method: > > public static void importFile(Node parentnode, > File file) throws RepositoryException, > IOException { > InputStream input = new FileInputStream(file); > > MimeTable mt = MimeTable.getDefaultTable(); > String mimeType = mt.getContentTypeFor(file.getName()); > if (mimeType == null) > mimeType = "application/octet-stream"; > > Node fileNode = parentnode.addNode(file.getName(), "nt:file"); > Node resNode = fileNode.addNode("jcr:content", "nt:resource"); > resNode.setProperty("jcr:mimeType", mimeType); > resNode.setProperty("jcr:encoding", ""); > resNode.setProperty(JcrConstants.JCR_DATA, > > resNode.getSession().getValueFactory().createBinary(input)); > Calendar lastModified = Calendar.getInstance(); > lastModified.setTimeInMillis(file.lastModified()); > resNode.setProperty("jcr:lastModified", lastModified); > System.out.println(fileNode.getPath()); > } > > > > > -- > View this message in context: > http://jackrabbit.510166.n4.nabble.com/Learning-Jackrabbit-Extracted-files-are-length-zero-tp4658373p4658375.html > Sent from the Jackrabbit - Users mailing list archive at Nabble.com.
