Unable to download pdf blob url on Safari -


currently using filereader open , view pdf works on chrome. however, when pdf opened on safari , click download button, nothing happens.

var reader = new filereader(); reader.onloadend = function(e) {     $window.location.href = reader.result; } reader.readasdataurl(file); 

after having spent entire day working on similar issue, understood problem can share knowledge you.

basically, kind of problems generated when render blob inside opened browser tab page url changes in like:

blob:http://localhost:8080/9bbeffe1-b0e8-485d-a8bd-3ae3ad9a0a51

the wrong procedure requiring pdf this:

var fileblob = new blob([response.data], {type: 'application/pdf'}); window.location.hfref = fileblob;

why doesn't work? well, can see pdf rendered on page might fooled thinking pdf loaded fine. however, if either try refresh page or download pdf on machine, doesn't work.

wth? so, thinking of sort of black magic going around browser, figured out problem: file doesn't exist cache stored inside browser. so, when generate blob , redirect current tab point generated blob url, lose cache.

now makes sense right?

  1. you request file on server
  2. the browser stores buffer inside tab
  3. you point page url read buffer
  4. you see pdf @ same time, lose buffer information

the think can do, opening blob url in new tab with:

window.open(fileblob, '_blank');

problem solved.


Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -