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
saiisaii 

File Download using the content disposition in response header in HTTP Request

Hi,

I am sending the request to Amazon s3 to get the file to be downloaded on desktop  from s3 amazon from my bucket.

Am able to send the Request and can get the content of file when am trying to download thefile . the file is not downloading . when am sending the Http Request to s3 .Here in response am sending the content- dispostion value in response bt the file is not downloading.

//Creating the Request to amazon

 


HttpRequest con = new HttpRequest();
con.setMethod('GET');
con.setEndPoint(Endpoint);
con.setHeader('x-amz-date', HIDATE );
con.setHeader('Authorization',AUTHORIZATION);

//Response From the Amazon
Http http = new Http();
HTTPResponse res = http.send(con);
res.setHeader('Content-Type:' ,'text/plain');
res.setHeader('Content-Disposition', 'attachment; filename='+filename+''); 
string contentLength=String.valueof(res.getBodyAsBlob().size());
system.debug('ContentLength'+contentLength);
String Last= res.getHeader('Last-Modified');

 

How to use the content dispostion when we are sending the Response the File to be downloaded