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?
Regards,
Stefan

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();
lastModified.setTimeInMillis(System.currentTimeMillis());
resNode.setProperty("jcr:lastModified", lastModified);

session.save();

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()), "default");

                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) {
                e.printStackTrace();
} catch (LoginException e) {
                e.printStackTrace();
} catch (RepositoryException e) {
                e.printStackTrace();
} finally {
                session.logout();
}
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.

Reply via email to