From users-return-6969-apmail-jackrabbit-users-archive=jackrabbit.apache.org@jackrabbit.apache.org Wed Apr 02 02:45:51 2008 Return-Path: Delivered-To: apmail-jackrabbit-users-archive@locus.apache.org Received: (qmail 72230 invoked from network); 2 Apr 2008 02:45:49 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 2 Apr 2008 02:45:49 -0000 Received: (qmail 8819 invoked by uid 500); 2 Apr 2008 02:45:48 -0000 Delivered-To: apmail-jackrabbit-users-archive@jackrabbit.apache.org Received: (qmail 8802 invoked by uid 500); 2 Apr 2008 02:45:48 -0000 Mailing-List: contact users-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@jackrabbit.apache.org Delivered-To: mailing list users@jackrabbit.apache.org Received: (qmail 8793 invoked by uid 99); 2 Apr 2008 02:45:48 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 01 Apr 2008 19:45:48 -0700 X-ASF-Spam-Status: No, hits=1.2 required=10.0 tests=SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: local policy) Received: from [66.216.121.145] (HELO smtp145.sat.emailsrvr.com) (66.216.121.145) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Apr 2008 02:44:58 +0000 Received: from relay4.relay.sat.mlsrvr.com (localhost [127.0.0.1]) by relay4.relay.sat.mlsrvr.com (SMTP Server) with ESMTP id C2DDB20A899 for ; Tue, 1 Apr 2008 22:45:12 -0400 (EDT) Received: by relay4.relay.sat.mlsrvr.com (Authenticated sender: dbrosius-AT-baybroadband.net) with ESMTP id 86F1D207454 for ; Tue, 1 Apr 2008 22:45:12 -0400 (EDT) Message-ID: <006a01c8946b$940b7710$6501a8c0@MeBigFatGuy> From: "Dave Brosius" To: References: <47F2A875.8040107@iastate.edu> Subject: Re: problems with getting binary data out of a repository Date: Tue, 1 Apr 2008 21:45:13 -0500 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=response Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.3138 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198 X-Virus-Checked: Checked by ClamAV on apache.org Don't use getString on a Binary property. Use getStream ----- Original Message ----- From: "Douglas Fils" To: Sent: Tuesday, April 01, 2008 4:26 PM Subject: problems with getting binary data out of a repository > Hello, > I am hoping someone can help me with getting binary data out of a > jackrabbit repository. I seem to be having some issues with that in an > application I am trying to work with. > > I can get data into the system with: > > Node root = session.getRootNode(); > Node fileNode = root.addNode(file.getOriginalFilename(), > "nt:file"); > Node resNode = fileNode.addNode("jcr:content", "nt:resource"); > resNode.setProperty("jcr:mimeType", file.getContentType()); > resNode.setProperty("jcr:encoding", ""); > resNode.setProperty("jcr:data", new > FileInputStream(tempFile.getAbsolutePath())); > Calendar lastModified = Calendar.getInstance(); > resNode.setProperty("jcr:lastModified", lastModified); > session.save(); > > This seems to work fine for getting files into the system and I can > reliably get them out with: > > Node mroot = session.getRootNode(); > Node root = mroot.getNode("${nodeName}/jcr:content"); > response.contentType = > root.getProperty("jcr:mimeType").getString() > response.outputStream << > root.getProperty("jcr:data").getString() > > for any text based files. However, whenever I try to do this with an > image or PDF the file end up corrupted. I assume the last .getString() is > doing bad things (converting my binary to string). > - Am I missing a flag I need to set when sending a file up to the system > that tells it is binary? > - Is jackrabbit doing a base64 serialization/deserialization behinds the > scenes? > - Is there same way to get the raw binary from the jcr:data node? > > If it makes any difference this is running in a spring environment and I > am letting spring set things up. > For text, it's all working fine.. just need it to do the same for binary. > Thanks! > Doug > > >