Skip to content

Commit

Permalink
chore: clean code
Browse files Browse the repository at this point in the history
  • Loading branch information
smarroufin committed Feb 1, 2024
1 parent 2101ceb commit 0ae27d8
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
1 change: 0 additions & 1 deletion _nuxthub/server/utils/blob.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ export function useBlob () {
baseURL: proxyURL,
method: 'HEAD'
})
console.log('head headers', headers.get('x-blob'))
return JSON.parse(headers.get('x-blob') || '{}') as BlobObject
}
// Use R2 binding
Expand Down
7 changes: 2 additions & 5 deletions server/api/storage/upload.post.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
export default eventHandler(async (event) => {
console.log('before')
const form = await readFormData(event)
console.log('getting file')
const file = form.get('file') as Blob
console.log('after')

if (!file || !file.size) {
throw createError({ status: 400, message: 'No file provided' })
throw createError({ statusCode: 400, message: 'No file provided' })
}

if (!file.type.startsWith('image/')) {
throw createError({ status: 400, message: 'File must be an image' })
throw createError({ statusCode: 400, message: 'File must be an image' })
}

return useBlob().put(`images/${file.name}`, file)
Expand Down

0 comments on commit 0ae27d8

Please sign in to comment.