【发布时间】:2020-11-22 04:21:23
【问题描述】:
Blob 存储在内存中。如果我创建了 6 个 blob,那么它们将存储在内存中。可以说它们不能被分配一个 url 或被设置为一个变量或任何类似的东西。如何访问它们?我根本不知道该怎么做。我希望能够得到一个包含在此页面上创建的所有 blob 的数组。
new Blob(['blob1'], {type: 'text/plain'});
new Blob(['blob2'], {type: 'text/plain'});
new Blob(['blob3'], {type: 'text/plain'});
new Blob(['blob4'], {type: 'text/plain'});
new Blob(['blob5'], {type: 'text/plain'});
new Blob(['blob6'], {type: 'text/plain'});
我想知道我怎样才能得到以下结果:
function getBlobs() {
//This is fake code
return Blobs.allBlobs;
}
console.log(getBlobs()) //Result would be the blobs
【问题讨论】:
-
这看起来像是某种假设的代码。 “Blob”类的定义在哪里?暂时忽略这一点,为什么不能将每个新 Blob 推送到一个数组中并使用它来跟踪“所有 Blob”?
标签: javascript memory blob