从IndexedDB条目中保存Arraybuffer

问题描述 投票:0回答:3

可以在indexedDB中存储blob和arraybuffers(正如你可以看到here)。我的问题是,我将pdf文件存储在存储中,并希望在用户点击特定链接时“下载”它们。是否可以从本地indexDB数据库“下载”文件?

html5 indexeddb
3个回答
1
投票

使用本机JavaScript或IndexedDB API是不可能的,但请查看即将推出的Filesystem API的FileWriter和BlobBuilder部分。


0
投票

这个问题与IndexedDB无关,而只是简单地说“如何让用户保存Blob对象”。 Blob以相同的方式工作,无论你是从IndexedDB加载它还是从其他地方获得它。

如果一直实施,使用FileSaver将是最好的解决方案,但事实并非如此。

应该做的是做这样的事情:

var iframe = document.createElement("iframe");
document.body.appendChild(iframe);
var url = URL.createObjectURL(blob); // This is the magic!
iframe.src = url;

0
投票

现在可以在indexedDb中保存Blob

objectStore.put({ id: idValue, blobdata: data })
© www.soinside.com 2019 - 2024. All rights reserved.