Status: New
Owner: ----
Labels: Type-Defect Priority-Unassigned
New issue 23344 by
daniel.a...@gmail.com: Dart2js 1.10, mogrified File is
no longer a subclass of Blob, so FileReader fails to load it.
https://code.google.com/p/dart/issues/detail?id=23344
What steps will reproduce the problem?
import "dart:html"
import 'package:chrome/chrome_app.dart' as chrome;
static Future<String> chooseFile(String description, List<String>
extensions) async {
log.info("chooseFile: (description='${description}',
extensions='${extensions}'");
if (!chrome.fileSystem.available) {
throw new StateError("Chrome fileSystem not available.");
}
// create the reader
// Both chrome api reader and html reader say File is not Blob now
var reader = new html.FileReader();
// assign the callback for the reader
var readerFuture = reader.onLoadEnd.first.then((e) {
log.info("chooseFile: .onLoadEnd e.target.result=${e.target.result}");
return e.target.result;
});
var fileEntry = await chrome.fileSystem.chooseEntry(new
chrome.ChooseEntryOptions(
type: chrome.ChooseEntryType.OPEN_FILE,
// do not use the acceptsMultiple field as it breaks things
// acceptsMultiple: false,
acceptsAllTypes: false, accepts: [
// TODO: ignoring extensions for now -- re-enable?
// new chrome.AcceptOption(description: description, extensions:
extensions)
new chrome.AcceptOption(description: description)
]));
var file = await (fileEntry.entry as chrome.FileEntry).file();
// Barfs here when run as javascript via Dart2JS,
//casting File to Blob causes class cast exception
reader.readAsText(file);
return readerFuture;
}
What is the expected output? What do you see instead?
FileReader readAsText should read contents of text file
What version of the product are you using?
1.10
On what operating system?
linux
What browser (if applicable)?
Chrome
Please provide any additional information below.
Get the following exception:
failed to execute 'readAsText' on 'FileReader': parameter 1 is not of
type 'Blob'
last worked under 1.8.5
Tried casting File to Blob before passing to FileReader.readAsText, get
class cast exception.
html.FileReader and chrome api FileReader both report the passed in File is
not a Blob. API docs say File is a subclass of Blob. Worked under 1.8.5.
https://api.dartlang.org/apidocs/channels/be/dartdoc-viewer/dart:html.File
Says File extends Blob
--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings