URL.createObjectURL(blob)
稳定性: 1 - 实验性的
¥Stability: 1 - Experimental
创建表示给定的 <Blob> 对象并且可用于稍后检索 Blob
的 'blob:nodedata:...'
网址字符串。
¥Creates a 'blob:nodedata:...'
URL string that represents the given <Blob>
object and can be used to retrieve the Blob
later.
const {
Blob,
resolveObjectURL,
} = require('node:buffer');
const blob = new Blob(['hello']);
const id = URL.createObjectURL(blob);
// later...
const otherBlob = resolveObjectURL(id);
console.log(otherBlob.size);
已注册的 <Blob> 存储的数据将保留在内存中,直到调用 URL.revokeObjectURL()
将其删除。
¥The data stored by the registered <Blob> will be retained in memory until
URL.revokeObjectURL()
is called to remove it.
Blob
对象已在当前线程中注册。如果使用工作线程,则在工作线程内注册的 Blob
对象将不能被其他工作线程或主线程使用。
¥Blob
objects are registered within the current thread. If using Worker
Threads, Blob
objects registered within one Worker will not be available
to other workers or the main thread.