Skip to content

Commit

Permalink
fix(blob): respect addRandomSuffix with remote access (#287)
Browse files Browse the repository at this point in the history
  • Loading branch information
atinux authored Sep 16, 2024
1 parent fd3c5f0 commit d91c815
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 3 additions & 1 deletion playground/server/api/browser/capture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ export default eventHandler(async (event) => {

// Upload the screenshot to the Blob storage
const filename = `screenshots/${btoa(url + theme)}.jpg`
await hubBlob().put(filename, screenshot)
await hubBlob().put(filename, screenshot, {
addRandomSuffix: false
})
await page.close()

setHeader(event, 'content-type', 'image/jpeg')
Expand Down
2 changes: 2 additions & 0 deletions src/runtime/blob/server/api/_hub/blob/[...pathname].put.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ export default eventHandler(async (event) => {
options.customMetadata = {}
}
}
// sanitize addRandomSuffix which is a boolean
options.addRandomSuffix = options.addRandomSuffix === 'true'

const stream = getRequestWebStream(event)!
const body = await streamToArrayBuffer(stream, Number(contentLength))
Expand Down

0 comments on commit d91c815

Please sign in to comment.