Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Referencing <a href="https://stackoverflow.com/a/6740027/586621">this post</a> I've thrown together quick demonstration on how this may be done using AngularJS:</p> <p><a href="http://plnkr.co/edit/u4r2ufEfUueSC55sWj9f?p=preview" rel="nofollow noreferrer">JavaScript Demo (Plunker)</a></p> <p>I've wrapped the referenced Base64 code in a service, and use it in the following way:</p> <pre class="lang-js prettyprint-override"><code>$scope.downloadCSV = function() { var data = Base64.encode($scope.CSVData); window.location.href = "data:text/csv;base64," + data; }; </code></pre> <p>There <a href="http://en.wikipedia.org/wiki/Data_URI_scheme#Disadvantages" rel="nofollow noreferrer">are some disadvantages</a> to this method however as mentioned in the comments. I've pulled out some bullet points from the Wikipedia page on this subject. Head over there for the full list.</p> <blockquote> <ul> <li>Data URIs are not separately cached from their containing documents (e.g. CSS or HTML files), therefore the encoded data is downloaded every time the containing documents are re-downloaded.</li> <li>Internet Explorer 8 limits data URIs to a maximum length of 32 KB. (Internet Explorer 9 does not have this limitation)</li> <li>In IE 8 and 9, data URIs can only be used for images, but not for navigation or JavaScript generated file downloads.[7]</li> <li>Base64-encoded data URIs are 1/3 times larger in size than their binary equivalent. (However, this overhead is reduced to 2–3% if the HTTP server compresses the response using gzip)</li> <li>Data URIs do not carry a filename as a normal linked file would. When saving, a default filename for the specified MIME type is generally used.</li> <li>[ . . . ]</li> </ul> </blockquote>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload