Skip to content

Commit d83bfe8

Browse files
committed
baby step
1 parent d2fa134 commit d83bfe8

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

packages/hub/src/utils/WebBlob.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export class WebBlob extends Blob {
6060

6161
override slice(start = 0, end = this.size): WebBlob {
6262
if (start < 0 || end < 0) {
63-
new TypeError("Unsupported negative start/end on FileBlob.slice");
63+
new TypeError("Unsupported negative start/end on WebBlob.slice");
6464
}
6565

6666
const slice = new WebBlob(

packages/hub/src/utils/XetBlob.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import type { CredentialsParams } from "../types/public";
2+
import { checkCredentials } from "./checkCredentials";
3+
4+
type XetBlobCreateOptions = {
5+
/**
6+
* Custom fetch function to use instead of the default one, for example to use a proxy or edit headers.
7+
*/
8+
fetch?: typeof fetch;
9+
} & Partial<CredentialsParams>;
10+
11+
/**
12+
* XetBlob is a blob implementation that fetches data directly from the Xet storage
13+
*/
14+
export class XetBlob extends Blob {
15+
fetch: typeof fetch;
16+
accessToken?: string;
17+
18+
constructor(params: XetBlobCreateOptions) {
19+
super([]);
20+
21+
this.fetch = params.fetch ?? fetch;
22+
this.accessToken = checkCredentials(params);
23+
}
24+
}

0 commit comments

Comments
 (0)