文件 API:返回文件引用(对象)或整个文件内容(字符串)?
在 plupload (plupload.html5.js) 中,我看到以下代码:
// Blob is string so we need to fake chunking, this is not
// ideal since the whole file is loaded into memory
if (typeof(blob) == 'string') {
chunkBlob = blob.substring(chunk * chunkSize, chunk * chunkSize + curChunkSize);
} else {
// Slice the chunk
chunkBlob = blob.slice(chunk * chunkSize, curChunkSize);
}
我想知道该 blob 是否可以是字符串?正如我从源代码中看到的那样,blob 变量应该包含(我认为它应该包含)对用户选择的文件的文件引用,因此它表达了这样的内容:
<input type="file" onchange="var thatBlob = this.files[0]" />
从注释中我看到它可能会返回整个文件内容,而不是而不是对它的引用。怎么会?
有什么我不明白的吗?
In the plupload (plupload.html5.js), I see this code:
// Blob is string so we need to fake chunking, this is not
// ideal since the whole file is loaded into memory
if (typeof(blob) == 'string') {
chunkBlob = blob.substring(chunk * chunkSize, chunk * chunkSize + curChunkSize);
} else {
// Slice the chunk
chunkBlob = blob.slice(chunk * chunkSize, curChunkSize);
}
And I wonder if that blob can be a string? As I can see from the source that blob variable should contain (I think it should contain) the file reference to a file selected by user, so it expresses something like this:
<input type="file" onchange="var thatBlob = this.files[0]" />
From the comments I see that it may return the whole file content rather than a reference to it. How come?
Is there something I don't understand?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,我错过了他们还使用 getAsBinary() (返回字符串)。
Ok, I missed it out that they also use getAsBinary() (that returns string).