3

Does the Chrome Javascript API support downloading a file in several chunks simultaneously? eg in a download manager.

Qantas 94 Heavy
  • 15,750
  • 31
  • 68
  • 83

1 Answers1

2

Short answer: no, no special support. There is a dedicated chrome.downloads API, but it's just the same mechanism as normal Chrome downloads, i.e. single stream.

Long answer: You can make it yourself via XMLHttpRequest by setting range attributes, e.g.

xhr.setRequestHeader("Range", "bytes=100-200");

See more information here, and potential problems you can run into in this question.

Community
  • 1
  • 1
Xan
  • 74,770
  • 16
  • 179
  • 206
  • If this gives me the error `Request header field Range is not allowed by Access-Control-Allow-Headers.` can I get around that? –  Apr 27 '14 at 06:06
  • Just found out that's same origin policy. There goes my plans... thanks anyway. –  Apr 27 '14 at 06:18
  • @mm865 Do you have permissions for the site in question in the manifest? – Xan Apr 27 '14 at 09:03
  • Im just discovering all this documentation i havent seen. My extension will need to request from any site, so i will use `http://*/` and `https://*/`. I will set aboout readong the documentation first though. –  Apr 27 '14 at 11:32
  • @mm865 There is a `` match pattern that will do it. If you have a permission for a website, many origin permissions are bypassed with XHR. – Xan Apr 27 '14 at 11:43