Issue 23344 in dart: Dart2js 1.10, mogrified File is no longer a subclass of Blob, so FileReader fails to load it.

5 views
Skip to first unread message

da...@googlecode.com

unread,
Apr 29, 2015, 2:57:07 PM4/29/15
to bu...@dartlang.org
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

da...@googlecode.com

unread,
Apr 29, 2015, 3:17:28 PM4/29/15
to bu...@dartlang.org

Comment #1 on 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

Adding

log.info("Type is: ${file.toString()}, ${file.runtimeType}");
window.console.log(file);

Prints out

Type is: [object File], E4
E4 {Q: File, ^: "a;Q", p: function, q: function, giO: function…}
Q: File___dart__$dart_dartObject_ZxYxX_0_: E4lastModified:
1430327389807lastModifiedDate: Wed Apr 29 2015 10:09:49 GMT-0700
(PDT)name: "scout_db.json"size:
1886603type: ""webkitRelativePath: ""__proto__: File__proto__: E4

da...@googlecode.com

unread,
Apr 29, 2015, 3:26:56 PM4/29/15
to bu...@dartlang.org

Comment #2 on 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

I suspect it may be related to this, as File is supposedly a subclass of
Blob

https://code.google.com/p/dart/issues/detail?id=15053

da...@googlecode.com

unread,
Apr 29, 2015, 5:07:29 PM4/29/15
to bu...@dartlang.org

Comment #3 on 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

This all worked JUST FINE in 1.8.5 but is halting work on our dart chrome
app

da...@googlecode.com

unread,
Apr 30, 2015, 5:22:37 PM4/30/15
to bu...@dartlang.org
Updates:
Status: Triaged
Cc: te...@google.com
Labels: Area-Library Library-Html

Comment #4 on issue 23344 by floi...@google.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

(No comment was entered for this change.)

da...@googlecode.com

unread,
May 1, 2015, 1:18:22 PM5/1/15
to bu...@dartlang.org

Comment #5 on 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

Our workaround is now to call out to the Javascript chrome.filesystem api
with a minimal wrapper.

da...@googlecode.com

unread,
May 1, 2015, 1:56:26 PM5/1/15
to bu...@dartlang.org
Updates:
Status: Accepted
Labels: -Priority-Unassigned Priority-Medium

Comment #6 on issue 23344 by alank...@google.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

This is an unstable and Chrome-specific API, so it's entirely possible
something changed in Chrome that invalidated this. But it doesn't seem to
be the subclassing. File definitely extends Blob in the Dart sources, and
in the Chrome IDL. Calling out to JS is probably the best workaround.

da...@googlecode.com

unread,
Jun 2, 2015, 4:36:34 PM6/2/15
to bu...@dartlang.org

Comment #7 on 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

Its borked in the prototype chain when you print it out and examine what
dart2js generated.
Reply all
Reply to author
Forward
0 new messages