jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Droog <sdr...@educator.eu>
Subject Creating PDF/PNG/TXT from inputstream doesn't work, JPG/html does
Date Thu, 14 May 2009 13:01:24 GMT
I want to send e.g. a PDF file to the client. It does work for JPG and Html but not for PDF
/ PNG / TXT files.

When I try to open the file I get Adobe Reader could not open FILENAME because it is either
not a supported file type or because the file has been damaged(for example, it was sent as
an email attachment and wasn't correctly decoded).

Content type is "application/pdf".

Somebody a clue?

Store uploaded file

Node fileNode = user.addNode(upload.getClientFileName(), "nt:file");

Node resNode = fileNode.addNode("jcr:content", "nt:resource");

resNode.setProperty("jcr:mimeType", upload.getContentType());
resNode.setProperty("jcr:data", upload.getInputStream());
Calendar lastModified = Calendar.getInstance();
resNode.setProperty("jcr:lastModified", lastModified);


Stream uploaded file to client when user press' button:

Session session = null;
try {
Repository repository = new TransientRepository();
                session = repository.login(new SimpleCredentials("johndoe", "password".toCharArray()),

                Node root = session.getRootNode();
                Node user = root.getNode(m_userService.getCurrentUser().getUsername());

                NodeIterator fileNodeIterator = user.getNodes();
                Node file = fileNodeIterator.nextNode();

                Node content = file.getNode("jcr:content");

                m_in = content.getProperty("jcr:data").getStream();
                m_mime = content.getProperty("jcr:mimeType").getString();
} catch (IOException e) {
} catch (LoginException e) {
} catch (RepositoryException e) {
} finally {
return m_in;

The information contained in this communication is confidential, intended solely for the use
of the individual or entity to whom it is addressed and may be legally privileged and protected
by professional secrecy. Access to this message by anyone else is unauthorized. If you are
not the intended recipient, any disclosure, copying, or distribution of the message, or any
action or omission taken by you in reliance on it is prohibited and may be unlawful. Please
immediately contact the sender if you have received this message in error. This email does
not constitute any commitment from Cordys Holding BV or any of its subsidiaries except when
expressly agreed in a written agreement between the intended recipient and Cordys Holding
BV or its subsidiaries. Cordys is neither liable for the proper and complete transmission
of the information contained in this communication nor for any delay in its receipt. Cordys
does not guarantee that the integrity of this communication has been maintained nor that the
communication is free of viruses, interceptions or interference. If you are not the intended
recipient of this communication please return the communication to the sender and delete and
destroy all copies.

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