more stuff

This commit is contained in:
Jeff Emmett 2024-08-30 09:44:11 +02:00
parent 80cda32cba
commit 2c4b2f6c91
2 changed files with 21 additions and 15 deletions

View File

@ -10,6 +10,7 @@ function getAssetObjectName(uploadId: string) {
// when a user uploads an asset, we store it in the bucket. we only allow image and video assets. // when a user uploads an asset, we store it in the bucket. we only allow image and video assets.
export async function handleAssetUpload(request: IRequest, env: Environment) { export async function handleAssetUpload(request: IRequest, env: Environment) {
try {
const objectName = getAssetObjectName(request.params.uploadId) const objectName = getAssetObjectName(request.params.uploadId)
const contentType = request.headers.get('content-type') ?? '' const contentType = request.headers.get('content-type') ?? ''
@ -26,6 +27,10 @@ export async function handleAssetUpload(request: IRequest, env: Environment) {
}) })
return { ok: true } return { ok: true }
} catch (error) {
console.error('Asset upload failed:', error);
return new Response(`Upload failed: ${(error as Error).message}`, { status: 500 });
}
} }
// when a user downloads an asset, we retrieve it from the bucket. we also cache the response for performance. // when a user downloads an asset, we retrieve it from the bucket. we also cache the response for performance.

View File

@ -26,3 +26,4 @@ binding = 'TLDRAW_BUCKET'
bucket_name = 'jeffemmett-canvas' bucket_name = 'jeffemmett-canvas'
preview_bucket_name = 'jeffemmett-canvas-preview' preview_bucket_name = 'jeffemmett-canvas-preview'
workers_dev = true workers_dev = true
logpush = true