@abraca/dabra 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -7501,6 +7501,30 @@ var FileBlobStore = class extends EventEmitter {
|
|
|
7501
7501
|
this.objectUrls.set(key, url);
|
|
7502
7502
|
return url;
|
|
7503
7503
|
}
|
|
7504
|
+
/**
|
|
7505
|
+
* Store a blob directly into the cache under the given (docId, uploadId) key
|
|
7506
|
+
* and return its object URL. Use this to pre-populate the cache for files
|
|
7507
|
+
* that haven't been uploaded to the server yet (e.g. offline upload queue).
|
|
7508
|
+
*/
|
|
7509
|
+
async putBlob(docId, uploadId, blob, filename) {
|
|
7510
|
+
if (typeof window === "undefined") return URL.createObjectURL(blob);
|
|
7511
|
+
const key = this.blobKey(docId, uploadId);
|
|
7512
|
+
const existing = this.objectUrls.get(key);
|
|
7513
|
+
if (existing) return existing;
|
|
7514
|
+
const db = await this.getDb();
|
|
7515
|
+
if (db) {
|
|
7516
|
+
const entry = {
|
|
7517
|
+
blob,
|
|
7518
|
+
mime_type: blob.type || "application/octet-stream",
|
|
7519
|
+
filename,
|
|
7520
|
+
cachedAt: Date.now()
|
|
7521
|
+
};
|
|
7522
|
+
db.transaction("blobs", "readwrite").objectStore("blobs").put(entry, key);
|
|
7523
|
+
}
|
|
7524
|
+
const url = URL.createObjectURL(blob);
|
|
7525
|
+
this.objectUrls.set(key, url);
|
|
7526
|
+
return url;
|
|
7527
|
+
}
|
|
7504
7528
|
/** Revoke the object URL and remove the blob from cache. */
|
|
7505
7529
|
async evictBlob(docId, uploadId) {
|
|
7506
7530
|
const key = this.blobKey(docId, uploadId);
|