Hi there,
I'm running into an issue while using this on Chrome for iOS: when the FileSaver.js code is called to save the blob from a canvas, a new tab is opened, but it's blank. The code is fairly similar to the project's demo code, except it runs on a 'click' event instead of a 'submit' event.
You can replicate this issue by doing the following:
The thing that's strange, though, is that the demo at http://eligrey.com/demos/FileSaver.js/ works for chrome on iOS. So there appears to be something breaking the saving on Chrome for iOS in the version that the demo loads in.
This code is pretty above my head, otherwise I'd help look into this, so I'm hoping you guys can help me figure this out.
Thanks,
Faison
I have the similar issue.
I've uploaded an example on gh-pages: http://alferov.github.io/filesaver-ios-issue/
It uses the latest code from both Filesaver and Blob projects.
I don't have any Apple devices, so you can submit pullreqs.
Hi @eligrey ,
Understandable. I could take a crack at it, but I'll need some direction. Do you have any initial thoughts of where in the code this issue could stem from? Any starting points would help me greatly.
Thanks,
Faison
Any updates to this problem?
Safari is still opening files in a new tab with blob:// in the address bar.
Plain text files are displayed in the tab but for example .xls files show just a blank tab.
Experiencing the same problem here in both my own code and the supplied demo.
Update: used Weinre to remote debug Chrome, but nothing useful there. Console didn't output anything.
same issue here, this is what I have done, but not the better way.
if(!navigator.userAgent.match('CriOS')) {
canvas.toBlob(function (blob) {
saveAs(blob, "screen.png");
} );
} else {
//for chrome in apple devices
var a = document.createElement('a');
a.href = canvas.toDataURL();
a.download = 'screen.png';
a.target='blank';
a.click();
}
Notes from my debugging:
var reader = new FileReader();
var blob = new Blob(['Hello world'], {type: 'text/plain'});
reader.onload = function(e){
window.location.href = reader.result
}
reader.readAsDataURL(blob);
data:attachment/file did not work for me. CriOS shown file for download, but with download error. After pressing download again button, error again.blob.type in datalink. It worked fine in CriOS.data:application/octet-stream it worked even if real Blob type was image/png, image was still shown.UPDATE 01:
"data:attachment/file" in CriOS using window.open(dataLink, '_blank'); shows empty page, nothing"data:attachment/file" in CriOS using window.location.href = dataLink; behaves as described above - shows download error.UPDATE 02:
"data:application/octet-stream" and "data:"+blob.type work in the same way for file types: pdf, png, csv, zip. PDF/PNGs are displayed on the page, same as CSV (text file). application/zip installed on iOS, using both datalink formats, just an empty tab is opened. UPDATE 03:
new Blob(["hello world"]), datalink still works, displays "hello world"UPDATE 04:
UPDATE 05:
window.open(object_url, '_blank'); and window.location.href = object_url;attachment/file, application/octet-stream, image/png, none of them worked. (During testing I modified the code so it does not fallback to datalink for application/octet-stream)@ph4r05 nice research
I still face the problem on IOS for pdf file, has it actually been solved?
@koop4 If you read the README.md then you will know the answear to your question:

Looks like there is still no good workaround for this, isn't it?
Most helpful comment
Notes from my debugging:
data:attachment/filedid not work for me. CriOS shown file for download, but with download error. After pressing download again button, error again.blob.typein datalink. It worked fine in CriOS.data:application/octet-streamit worked even if real Blob type wasimage/png, image was still shown.UPDATE 01:
"data:attachment/file"in CriOS usingwindow.open(dataLink, '_blank');shows empty page, nothing"data:attachment/file"in CriOS usingwindow.location.href = dataLink;behaves as described above - shows download error.UPDATE 02:
"data:application/octet-stream"and"data:"+blob.typework in the same way for file types:pdf, png, csv, zip. PDF/PNGs are displayed on the page, same as CSV (text file).application/zipinstalled on iOS, using both datalink formats, just an empty tab is opened.UPDATE 03:
new Blob(["hello world"]), datalink still works, displays"hello world"UPDATE 04:
UPDATE 05:
window.open(object_url, '_blank');andwindow.location.href = object_url;attachment/file,application/octet-stream,image/png, none of them worked. (During testing I modified the code so it does not fallback to datalink forapplication/octet-stream)