function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
SYM12SYM12 

How to view a file and save to local machine

Hi All,

 

i have saved a file to some third party sever. I am making an APi call retriving the file and below is the response

 

HTTP/1.1 200 Ok
Date: Wed, 11 Jul 2007 19:37:41 GMT
Server: Apache
Last-Modified: Fri, 12 Jun 2007 13:40:18 GMT
ETag: b0dffe8254d152d8fd28f3c5e0404a10
Content-type: text/html
Content-Length: 512000
[ ... ]  (file content)

 

Now i need to create a link (view ) in vf page, so when a  user click this link he should be able to download the file(same view functionality in document or we can say save as functionality).

 

Please let me know, Do i need to bulid the file again or Is there quick java script where i can pass all these values and it will take care rest.

 

Thanks in Advance!!

Pradeep_NavatarPradeep_Navatar

You can use following javascript to download a file :

 

            <body>

                <script>

                function downloadme(x)

                {

                myTempWindow = window.open(x,'','left=10000,screenX=10000');

                myTempWindow.document.execCommand('SaveAs','null','download.pdf');

                myTempWindow.close();

                }

                </script>

                <a href=javascript&colon;downloadme('/test.pdf');>Download this pdf</a>

           </body>

 

Hope this helps.

SYM12SYM12

Thanks Pradeep , But i dont have file path, i am getting response as a file content in response body.

 

Do i need to rebulid or file or any other way i can directly pass response to browser

Black Pearl.ax1741Black Pearl.ax1741

Hi,

I am facing exactly same issue.
Did you find any solution for it?

Thanks in advance.