I am trying to use resumable.js from Dart with this code:
var rs = new JS.JsObject(JS.context['Resumable'], [new JS.JsObject.jsify({
'target':context.server+'/upload'
})]);
files.forEach((file) {
rs.callMethod("addFile",[file]);
});
files
variable is defined as List<File>
(dart.html.File
). When I check properties of rs
object with these two lines:
JS.context["console"].callMethod("log",[rs['opts']]);
JS.context["console"].callMethod("log",[rs['files']]);
I find that rs.opts
are initialized correctly, but rs.files
always contains instances of ResumableFile
with length 1. I guess that it is because method addFile expects parameter to be instance of Javascript File
but it gets instanceof dart:html.File
.
Do you have any idea how to convert dart:html.File
to Javascript File
or how to pass argument to resumable.js?
I know that I can alternatively use methods assignBrowse
and assignDrop
, but I would like to stick to my solution.
答案 0 :(得分:2)
You have to use JsObject.fromBrowserObject to get the underlying js object.
files.forEach((file) {
rs.callMethod("addFile",[new JsObject.fromBrowserObject(file)]);
});