I have below code to download file from S3
public FileStreamResult Index(string key, string fileName)
{
GetObjectResponse resp = ReadS3Object("data", key);
StreamReader sr = new StreamReader(resp.ResponseStream);
var filresult = File(resp.ResponseStream, resp.ContentType);
Response.Clear();
Response.Buffer = true;
Response.ContentType = "application/vnd.ms-excel";
Response.AddHeader("content-disposition", "attachment; filename=fileName);
Response.Flush();
return filresult;
}
and Ajax call like below
$.ajax(
{
url: '/DownloadEstimation/Index',
contentType: 'application/json; charset=utf-8',
datatype: 'json',
data: {
key: key,
fileName: fname
},
type: "GET",
success: function () {
window.location = '/DownloadEstimation/'+ key + '/' + fname;
}
});
But it just call method, not prompting user to save the file
Any help highly appreciated.
Thanks