I'm returning an Excel file (which works fine) as octet stream from C# API using FileContentResult(byte[], MediaTypeNames.Application.Octet, "file.xlsx"
and then I'd want to open download file prompt from js and everything works fine except that the file is corrupted
I've been trying various solutions from these posts and Excel file always result in being corrupted
JavaScript: Create and save file
JavaScript blob filename without link
and also FileSaver.js
$.ajax({
url: url,
type: 'POST',
data: formData,
processData: false,
contentType: 'application/json',
success: function (result)
{
saveFile(result);
}
});
I know that file is working fine because when I'm testing it via Swagger then it works fine
Any ideas?