【发布时间】:2014-11-21 05:43:51
【问题描述】:
我想将文件从表单传输到网络工作者。在 chrome 中,我可以简单地使用此代码来传输 FileList-Object:
worker.postMessage(files: array_files);
但是使用 Firefox 我得到这个错误:
Transfer file to webworker: DataCloneError: The object could not be cloned.
所以我尝试将语法用于可转移对象。像这样?
var post = {files: array_files, file_ids: response.file_ids};
worker.postMessage(post, [post]);
但是我在 Chrome 中得到了这个
Uncaught DataCloneError: Failed to execute 'postMessage' on 'Worker': Value at index 0 does not have a transferable type.
还是这样
DataCloneError: The object could not be cloned.
在 Firefox 中。
将 FileList 传递给工作人员的正确方法是什么?
【问题讨论】:
-
存在 Mozilla 错误bugzilla.mozilla.org/show_bug.cgi?id=823484,所以除非有人修复它,否则你很不走运。实际上我愿意修复,但是我不喜欢制作 Firefox 版本,所以如果有人可以帮我制作它们,那么我可以处理代码
-
我遇到了同样的问题,
The object could not be cloned.那是因为我只是在我的消息中引用了参数。能否提供更多代码?
标签: file web-worker pass-data