Skip to content

Commit 24bae1f

Browse files
committed
feat: add blob store
1 parent 261bccd commit 24bae1f

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

src/helpers/blobs.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { Blobs } from '@netlify/blobs'
2+
import type { Blobs as IBlobs } from '@netlify/blobs'
3+
4+
let blobs: IBlobs
5+
6+
export const getBlobStorage = ({
7+
apiHost,
8+
token,
9+
siteID,
10+
deployId,
11+
}: {
12+
apiHost: string | undefined
13+
token: string | undefined
14+
siteID: string
15+
deployId: string | undefined
16+
}) => {
17+
if (!blobs && apiHost && token && siteID && deployId) {
18+
blobs = new Blobs({
19+
authentication: {
20+
apiURL: `https://${apiHost}`,
21+
token,
22+
},
23+
context: `deploy:${deployId}`,
24+
siteID,
25+
})
26+
}
27+
28+
return blobs
29+
}
30+
31+
export const isBlobStorageAvailable = async (netliBlob: IBlobs) => {
32+
try {
33+
await netliBlob.get('test')
34+
return true
35+
} catch {
36+
return false
37+
}
38+
}

0 commit comments

Comments
 (0)