You need to sign in to do that
Don't have an account?
Sumant Kuchipu 1
How to open Doc or CSV files on page from apex?
Hi,
We have custom attachment which attach the files to BOX (using REST API) and rendering attachment from there when the user clicks on "View" link. But the following functionolity works on PDF and image files, they are directly opening on next tab/window but when we click on Docs or CSV, the file is downloading direclty rather opening on new page. Please someone give me clues on this? see the following code snippet.
Apex Code:
Please help me on rendering doc/csv files on page rather downloading..
Appreciate your help..
Sumant K
We have custom attachment which attach the files to BOX (using REST API) and rendering attachment from there when the user clicks on "View" link. But the following functionolity works on PDF and image files, they are directly opening on next tab/window but when we click on Docs or CSV, the file is downloading direclty rather opening on new page. Please someone give me clues on this? see the following code snippet.
Apex Code:
public String fileOpen(){ HttpRequest req = new HttpRequest(); req.setEndpoint(fileDownloadURL); req.setMethod('GET'); Http binding = new Http(); HttpResponse res = binding.send(req); Blob boxFile = res.getBodyAsBlob(); String boxResponse = 'data:'+res.getHeader('Content-Type')+';base64,'+EncodingUtil.base64Encode(boxFile ); return boxResponse ; }VisualForce Page:
<apex:page controller="BoxController" action="{!fileOpen}"> <apex:form > <apex:outputText escape="false" value="{!boxResponse}"/> </apex:form> </apex:page>
Please help me on rendering doc/csv files on page rather downloading..
Appreciate your help..
Sumant K
To my knowledge this is totally a browser feature and nothing to do with APEX/Visualforce coding.
Below are links that should help you to understand how you can configure browser to open Word document in a specific browser
https://support.microsoft.com/en-us/kb/162059
http://www.howtogeek.com/howto/18948/view-docs-and-pdfs-directly-in-google-chrome/
Thanks,
Rangesh
Thanks for replying and information ..
Yes you are right, Salesforce doesn't have the functionolity to open docs/xls files on browser only downloading, so nothing I can do with Apex.
But since we have lot of users outside our org, it is difficult to tell them to change their browsers settings as you said ..
Lets see ..
Thanks,
Sumant K