![]() ![]() SaveAs(blob, 'test.pdf') //using FileSaver.js library This.prepareFile(reader.result, fileName) įetch the file from the web api, create a blob object, and use the FileSaver.js library ( ) to save the file, as below:īlob = new Blob(, ) Read the file using the FileReader, dynamically create a hyperlink with the href attribute set to the blob and the download property set to the filename, as below: ![]() On the Angular side (front-end), I have tried two options: = new .MediaTypeHeaderValue("application/octet-stream") = new .ContentDispositionHeaderValue("attachment") Inside the WebApi I am setting the Content-Disposition header to " attachment", and setting the filename to the appropriate value, as below: var result = new HttpResponseMessage(HttpStatusCode.OK) FYI, the files get downloaded fine when using the Safari browser on an iOS device. ![]() The files get downloaded fine on all mobile devices with the exception of an iOS device only when using a Chrome browser. I am working on an Angular application which connects with a Web Api to download files as a Blob. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |