Hi,
My requirement is to uploaded file should be display in page when ever i want to display pdf,ppt,doc, it should be display on page after clicking particular file name,below code i have writen but by default it is taking last condition am unable to display pdf file if i give jcr:content : property as::application/pdf then i can able to display pdf on page.
ResourceResolver resourceResolver = resolverFactory.getAdministrativeResourceResolver(null);
session = resourceResolver.adaptTo(Session.class);
Node node = session.getNode("/x/y/z/assets");
//System.out.println(node.getpath());
javax.jcr.ValueFactory valueFactory = session.getValueFactory();
javax.jcr.Binary contentValue = valueFactory.createBinary(is);
Node fileNode = node.addNode(fileName, "nt:file");
fileNode.addMixin("mix:referenceable");
Node resNode = fileNode.addNode("jcr:content", "nt:resource");
//String fileupld = "image/jpeg";
String fileupld = "application/x-mspowerpoint,application/x-compressed,application/excel,application/msword,application/pdf,text/plain,image/jpeg,";
That will be great for you answer
Solved! Go to Solution.
You can display this image of documents by using html img tag. Under a loop you can iterate all the uploaded documents and point the SRC attribute to the location of the file.
Views
Replies
Total Likes
You can display this image of documents by using html img tag. Under a loop you can iterate all the uploaded documents and point the SRC attribute to the location of the file.
Views
Replies
Total Likes
Thanks,
I have tried with your suggestion i gave loop condition pdf is displaying but coming to ppt and doc , it is displaying error as Refused to display:in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'.
Views
Replies
Total Likes
Step1: Create a bin class which will hold the location of each document when any uploading documents.
bean.setDocumentPath(node.getPath());
Step 2: iterate this bin object in your jsp as follows -
for(DocumentBean doc:docs){
%>
<a href="<%=doc.getDocumentPath()%>" target="_blank">
<img height="92" width="146" alt="Document" src='<%=doc.getImgUrl()%>'>
</a>
doc.getDocumentPath() should return the location : /content/mysite/somedoc.pdf
Hope it helps!
Thanks Sam for your reply.
Views
Replies
Total Likes
Please mark it as resolved if it helps!
Views
Replies
Total Likes
Views
Likes
Replies