Skip to content

Commit 068eee8

Browse files
authored
fix(blob): return null for get() with remote enabled (#455)
1 parent e618923 commit 068eee8

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

playground/server/api/blob/get/[...pathname].get.ts

+7
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,12 @@ export default eventHandler(async (event) => {
77

88
console.log('blob', blob)
99

10+
if (!blob) {
11+
throw createError({
12+
statusCode: 404,
13+
statusMessage: 'Blob not found'
14+
})
15+
}
16+
1017
return blob
1118
})

src/runtime/blob/server/utils/blob.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -408,10 +408,15 @@ export function proxyHubBlob(projectUrl: string, secretKey?: string, headers?: H
408408
method: 'GET'
409409
})
410410
},
411-
async get(pathname: string): Promise<Blob> {
411+
async get(pathname: string): Promise<Blob | null> {
412412
return await blobAPI(`/${encodeURIComponent(pathname)}`, {
413413
method: 'GET',
414414
responseType: 'blob'
415+
}).catch((e) => {
416+
if (e.status === 404) {
417+
return null
418+
}
419+
throw e
415420
})
416421
},
417422
async del(pathnames: string | string[]) {

0 commit comments

Comments
 (0)