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
Black Pearl.ax1741Black Pearl.ax1741 

How to save a file's content(bytestream) from HttpResponse object to a pdf.

On a page load(or a hyperlink click) I am calling a method which is calling a webservice. Webservice returns content of a pdf file(residing on jackrabbit content repository) as bytestream in the HttpResponse object in body. Now i have byte stream of the pdf file in the controller and want it to be downloaded at local machine of the end user who has opened this page(or clicked the hyperlink).

sfdcfoxsfdcfox
You won't be able to directly save to the user's machine from Apex Code. What you could do, though, is save the file to a Document, then pop up a new window that downloads the file using the standard salesforce.com download link. The new Summer 13 Apex Code, I believe, has a new system method that lets you dynamically determine the download link (see the release notes).