Skip to content

Commit

Permalink
fix(blob): return null for get() with remote enabled (#455)
Browse files Browse the repository at this point in the history
  • Loading branch information
atinux authored Feb 4, 2025
1 parent e618923 commit 068eee8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
7 changes: 7 additions & 0 deletions playground/server/api/blob/get/[...pathname].get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,12 @@ export default eventHandler(async (event) => {

console.log('blob', blob)

if (!blob) {
throw createError({
statusCode: 404,
statusMessage: 'Blob not found'
})
}

return blob
})
7 changes: 6 additions & 1 deletion src/runtime/blob/server/utils/blob.ts
Original file line number Diff line number Diff line change
Expand Up @@ -408,10 +408,15 @@ export function proxyHubBlob(projectUrl: string, secretKey?: string, headers?: H
method: 'GET'
})
},
async get(pathname: string): Promise<Blob> {
async get(pathname: string): Promise<Blob | null> {
return await blobAPI(`/${encodeURIComponent(pathname)}`, {
method: 'GET',
responseType: 'blob'
}).catch((e) => {
if (e.status === 404) {
return null
}
throw e
})
},
async del(pathnames: string | string[]) {
Expand Down

0 comments on commit 068eee8

Please sign in to comment.