Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8" />
  5. <title>Download large Blob Firefox issue on macOS</title>
  6. </head>
  7. <body>
  8. <h1>Download large Blob Firefox issue on macOS</h1>
  9. <h2>About</h2>
  10. <p>Attempting to download a blob URL on macOS over a certain size will hang at "A few seconds left" without ever finishing the download.</p>
  11. <p>However, if a <code>download</code> attribute is set on the link, like <code>download="file.zip"</code> (an empty download attribute doesn't work), it will complete, although it may have a short pause on "A few seconds left".</p>
  12. <p>Opening a tab to the blob URL or setting <code>window.location</code> to the blob URL also results in a hung download.</p>
  13. <h2>Examples</h2>
  14. <p>Click the following links for example downloads to demonstrate the problem (note the generated ZIP file is just a dummy file).</p>
  15. <ul>
  16. <li><a class="dl">No download attr</a> (Hangs)</li>
  17. <li><a class="dl" download>With download attr</a> (Hangs)</li>
  18. <li><a class="dl" download="file.zip">With download attr set</a> (Completes)</li>
  19. <li><a class="dl-location" href="#">window.location</a> (Hangs)</li>
  20. </ul>
  21. <script>
  22. (function() {
  23. 'use strict';
  24.  
  25. var parts = [
  26. new Uint8Array(0xFFFFFFF),
  27. new Uint8Array(0xFFFFFFF),
  28. new Uint8Array(0xFFFFFFF),
  29. new Uint8Array(0xFFFFFFF)
  30. ];
  31. var blob = new Blob(parts, {type: 'application/zip'});
  32. var url = URL.createObjectURL(blob);
  33.  
  34. Array.prototype.forEach.call(document.querySelectorAll('.dl'), function(el) {
  35. el.href = url;
  36. });
  37. Array.prototype.forEach.call(document.querySelectorAll('.dl-location'), function(el) {
  38. el.addEventListener('click', function(e) {
  39. e.preventDefault();
  40. window.location = url;
  41. });
  42. });
  43.  
  44. })();
  45. </script>
  46. </body>
  47. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement