Download large files in Dartlang

2019-05-28 10:25发布

问题:

I need to download largish files from a browser using dartlang.

I've been using the "data:uri" thing to download, but have hit the size limitations of that method.

Wondering what the best method for this is, I looked into using the HTML5 filesystem API but that is deprecated (without ever really being implemented in most browsers apparently.

回答1:

<a id='downloadLink' href='javascript:void(0)' download='Hello.txt'>Download</a>

import 'dart:html';

void main() {
  var data = new Blob(['Hello World!\n'*1000000]);
  querySelector("#downloadLink")
      ..setAttribute('href', Url.createObjectUrl(data));
}


标签: html html5 dart