ng-csv
ng-csv copied to clipboard
filename attr is not woking in Safari
Thank you for this code (ng-csv). I used it in my project.
However, in Safari, csv file is not download. It is printed in Safari browser's new tab. Aslo in Chrome browser filename attr is not working.
(Firefox is ok)
Hi, Thanks for the report, Apparently Google pushed a bug in the latest version of Chrome. https://code.google.com/p/chromium/issues/detail?id=376197
I hope they will solve this soon enough, I'll check up on this in the next couple of days and if I won't see any progress I will try to find a workaround.
On Tue, May 27, 2014 at 9:58 AM, jeonghwan [email protected] wrote:
Thank you for this code (ng-csv). I used it in my project.
However, in Safari, csv file is not download. It is printed in Safari browser's new tab. Aslo in Chrome browser filename attr is not working.
(Firefox is ok)
— Reply to this email directly or view it on GitHubhttps://github.com/asafdav/ng-csv/issues/29 .
Thank you for comment. :D
The Chromium team merged the issue into this one https://code.google.com/p/chromium/issues/detail?id=373182
It should be fixed in a week or two. let's cross our fingers.
I expect.
Same issue. Hoping for a resolution.
According to issue above, they solved it today, so we should expect a fix soon.
I'm using chrome Version 35.0.1916.153 latest. When I click on export, it always choose "download.csv" as the filename even if I have the filename="export.csv" attribute set.
Also, I have the same issue as mentioned above where safari opens the CSV in a new tab.
I am facing the same issue with Chrome and Safari. Do we have any work around at this moment?
Hi,
I don't have a good solution for Safari at the moment, as currently they ignore the html5 download attribute. We can try to find a good flash polyfill that will allow us to bypass that, Downloadify seems like a good option. If any of you have the time for it, I'll be more than happy to accept a pull request :)
As I mentioned above, The chrome team already solved the issue and the next version is just around the corner, If you use Chrome beta or Canary you can already see the it's solved. I hope it's a matter of days.
On Wed, Jul 9, 2014 at 7:54 AM, Aditya Sabnis [email protected] wrote:
I am facing the same issue with Chrome and Safari. Do we have any work around at this moment?
— Reply to this email directly or view it on GitHub https://github.com/asafdav/ng-csv/issues/29#issuecomment-48429965.
hi, for a rapid solution of chrome problem, you can modify ng-csv.js else in line 211 for that
else {
var blob = new Blob([scope.csv],{
type: 'text/csv'
});
var csvUrl = URL.createObjectURL(blob);
var downloadLink = angular.element('<a></a>');
downloadLink.attr('href',csvUrl);
downloadLink.attr('download',scope.getFilename());
$document.find('body').append(downloadLink);
$timeout(function() {
downloadLink[0].click();
downloadLink.remove();
}, null);
}
UPDATE: The latest version of chrome works as expected
Thanks I will check it.
Any updates about this? On safari i will get printed output, not a downloaded file..
Same here, safari doesn't download the file. Any idea how to work around this issue?
how it's going?
This is because Safari doesn't allow downloading of blob urls. So FileSaver.js using base64data in case of Safari browser. How about using this code on Safari in our project?
if (isSafari()) {
downloadContainer = angular.element('<div data-tap-disabled="true"><a></a></div>');
downloadLink = angular.element(downloadContainer.children()[0]);
// Safari doesn't allow downloading of blob urls
var reader = new FileReader();
reader.readAsDataURL(blob);
reader.onloadend = function() {
var base64data = reader.result;
downloadLink.attr('href', 'data:attachment/file' + base64data.slice(base64data.search(/[,;]/)));
};
$document.find('body').append(downloadContainer);
$timeout(function () {
downloadLink[0].click();
downloadLink.remove();
}, null);
}
Has there been any progress on this issue?
So I've been doing some research into this. It looks like Safari doesn't support the download attribute used in the dynamically created element in the directive's link function. From what I've been able to find, other developers have either directed their users through non-intuitive right-click then "save page as" or create a content stream that still results in losing the filename. I'll keep looking into this and if I find a work around or something that looks like it fits into ng-csv's without a lot of bloat I'll let yall know / make a pull request.
I'm afraid I've had something higher priority come up but if I have a chance I'll get back to this.
@asafdav - seems that Chrome 48.0.2564.116m on windows10 still doesn't have extname on the file.
It's working like a charm on chrome. However, in Safari, csv file is not download yet. I'll try find a solution for it and make a PR guys. BTW... great work on this directive! :clap:
@jeonghwan-kim I tried your code but unfortunately it didn't worked. Did you find a solution for it?
- one same problem in safari. Thanks @diego-oliveira, let us know if you find anything. ;-)
@diego-oliveira : @jeonghwan-kim 's solution works fine when taken as a whole.
@asafdav If there's something wrong with the above (besides that it's not a pull request) or with @karrde00 's pull request, please comment on them - I'd be happy to help clean up, etc., if needed.
@jnelson I'll give it a shoot again and see if it was some mistake from my side. Thanks.
@diego-oliveira If you prefer the iframe approach, we have an up-to-date merge of @karrde00's pull request at https://github.com/xlhybridsOSS/ng-csv/tree/github_karrde00-master - initial testing against IE11 and Safari 9.1 for our immediate problem has been successful.
Thanks guys for working on this! We just ran into an issue where a client tried to download our data in CSV on Safari and it did not work :(
Has anyone managed to get either of the above solutions working on Safari for iPad / iPhone? Nothing happens when I click my save button using @jeonghwan-kim 's solution and I get an "unable to read file" error using @karrde00 's solution.
I also cannot download using the Android built-in browser, using any solution. It works in Chrome for Android though. Haven't seen anyone else mention this problem...
+1
+1
+1
+1
+1
+1
downloadLink.attr('target', '_blank');
line prevent safari from downloading file. With this line it opens file in new tab while without it safari downloading file as expected.
+1, any news?
@Novarg I tried commenting on that line that you mention and it works in Safari and Chrome, you should do a pull request with that change
+1
+1