+ Start a Discussion
Praveen Kumar 9Praveen Kumar 9 

Download and stay on the same page

I  have a requirement like when the user clicks on a link it returns a download link and user should be able to download that file and stay on the same page.

 The problem is when the DL link is posted or redirected using page reference the page refreshes and gives a blank page.

any suggestion on how this could be done 
Hi Praveen,

Can you please show the code.

You can use return type of the method as pageReference.
and return null at the end of the method, so then it will be on the same page

AbhI Tripathi
SFDC Certified Developer
Why don't you try referring the same page once you click on the link...using page reference
Praveen Kumar 9Praveen Kumar 9
Thank you Vamshi and Abhi for the reply

This is the code we are trying - This get executed ocne the user clicks a file name

            String FileValue = filesToIdMap.get(fileName);
            string endPointValue = 'https://api.box.com/2.0/files/'+FileValue+'/content';
            req.setHeader('Authorization:', 'Bearer ' + getAccessToken());
            HttpResponse res = h.send(req);
            system.debug('$$$$$$$$ res --> ' +res);
            system.debug('$$$$$$$$ res Header Location --> ' +res.getheader('Location'));

The returned value 'Location'  is the temporary DL link given by BOX ( another cloud storage and we are doing SF to Box integration ) .

So now once the Location is returned we have to make sure the user get the DL file , as well as staying in the same page.

If i do pagereferance to the 'Location' what happens is the file gets downloaded and blank page is displayed. I want to return back to the old page.