"Failed - Network Error" When trying to provide download in HTML5 using 'download' attribute "Failed - Network Error" When trying to provide download in HTML5 using 'download' attribute flask flask

"Failed - Network Error" When trying to provide download in HTML5 using 'download' attribute


Apparently this is a Chrome issue with the data-URL getting too long. I'm still working through it myself, but there apparently are some solutions involving Blob-objects.

See here: Download Canvas as PNG in fabric.js giving network Error

And here: How to export JavaScript array info to csv (on client side)?


Based on How to export JavaScript array info to csv (on client side)? here is how I've implemented a solution for this issue:

Note that I only needed a solution for Chrome - web, so this is what I used. For a complete solution you'll need to check out the examples in the original answ

$.ajax({    url: "/getData",    dataType: "text",    success: function(data){                    $("#download").attr({            "value": "Download",            "href": URL.createObjectURL(new Blob([data], {                  type: "application/octet-stream"            })),            "download": "outputFile.csv"        });    }});