File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments