我想将文件从表单传输到网络工作者。在 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.
在火狐中。
将 FileList 传递给工作人员的正确方法是什么?