Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions packages/transformers/src/utils/cache/CrossOriginStorageCache.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,13 @@ export class CrossOriginStorage {
return undefined;
}
try {
const [handle] = await navigator.crossOriginStorage.requestFileHandles([makeHashDescriptor(hashValue)]);
const handle = await navigator.crossOriginStorage.requestFileHandle(makeHashDescriptor(hashValue));
const blob = await handle.getFile();
return new Response(blob);
return new Response(blob, {
headers: {
'Content-Length': String(blob.size),
},
});
} catch {
return undefined;
}
Expand Down Expand Up @@ -106,7 +110,7 @@ export class CrossOriginStorage {
* @returns {Promise<void>}
*/
_storeBlobInCOS = async (blob, hashHex) => {
const [handle] = await navigator.crossOriginStorage.requestFileHandles([makeHashDescriptor(hashHex)], {
const handle = await navigator.crossOriginStorage.requestFileHandle(makeHashDescriptor(hashHex), {
create: true,
});
const writableStream = await handle.createWritable();
Expand Down
10 changes: 5 additions & 5 deletions packages/transformers/src/utils/cache/cross-origin-storage.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
*/

/**
* Represents the dictionary for hash algorithms and values.
* Represents the dictionary for hash algorithm and value.
*/
interface CrossOriginStorageRequestFileHandleHash {
value: string;
algorithm: string;
}

/**
* Represents the options for requesting file handles.
* Represents the options for requesting a file handle.
*/
interface CrossOriginStorageRequestFileHandleOptions {
create?: boolean;
Expand All @@ -24,10 +24,10 @@ interface CrossOriginStorageRequestFileHandleOptions {
* [SecureContext]
*/
interface CrossOriginStorageManager {
requestFileHandles(
hashes: CrossOriginStorageRequestFileHandleHash[],
requestFileHandle(
hash: CrossOriginStorageRequestFileHandleHash,
options?: CrossOriginStorageRequestFileHandleOptions,
): Promise<FileSystemFileHandle[]>;
): Promise<FileSystemFileHandle>;
}

/**
Expand Down
Loading