3

I'm trying to support downloading a file from an API in Edge on iOS. The file is downloaded as a blob, and we already have solutions in place for downloading on Safari and Chrome (Using createObjectUrl and readAsDataUrl respectively), but neither of these seem to work on Edge on iOS.

I can't find anything online around how to do this, and even FileReader doesn't seem to support it.

I have tried to download using solutions that work consistently in Chrome on iOS and Safari on iOS.

Edit: Edge on iOS uses Safari's rendering engine, so any IE11 or Edge on Desktop focused solutions will not work here.

2
  • Possible duplicate of Open links made by createObjectURL in IE11 Commented Jan 25, 2019 at 11:39
  • 1
    @BlueWater86 This is talking about Edge on iOS, which uses Apple's rendering engine. IE or Desktop Edge focused solutions will not work here. Commented Jan 28, 2019 at 23:10

1 Answer 1

2

In the IE/Edge browser, you could try to use window.navigator.msSaveOrOpenBlob method to download the file. You could check these article: thread 1 and article 1. Code like this:

showFile(blob){ // It is necessary to create a new blob object with mime-type explicitly set // otherwise only Chrome works like it should var newBlob = new Blob([blob], {type: "application/pdf"}) // IE doesn't allow using a blob object directly as link href // instead it is necessary to use msSaveOrOpenBlob if (window.navigator && window.navigator.msSaveOrOpenBlob) { window.navigator.msSaveOrOpenBlob(newBlob); return; } // For other browsers: // Create a link pointing to the ObjectURL containing the blob. const data = window.URL.createObjectURL(newBlob); var link = document.createElement('a'); link.href = data; link.download="file.pdf"; link.click(); setTimeout(function(){ // For Firefox it is necessary to delay revoking the ObjectURL window.URL.revokeObjectURL(data); , 100} } 
Sign up to request clarification or add additional context in comments.

1 Comment

This doesn't work on Edge iOS - it is built on Safari's engine and doesn't containwindow.navigator.msSaveOrOpenBlob

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.