fix: create project-thumbnails bucket in instrumentation.ts (#118)
The thumbnail upload (uploadProjectThumbnail) writes to a 'project-thumbnails' storage bucket, but instrumentation.ts only bootstrapped the 'avatars' bucket. This caused: Upload failed: Bucket not found Add the missing bucket creation with matching constraints (public, 10 MB limit, image/png only). Also refactor the bucket-exists check to use a Set so it scales cleanly as more buckets are added. Co-authored-by: Anton Pascal <anton-pascal@users.noreply.github.com>
This commit is contained in:
@@ -10,9 +10,9 @@ export async function register() {
|
||||
const supabase = createClient(url, key)
|
||||
|
||||
const { data: buckets } = await supabase.storage.listBuckets()
|
||||
const exists = buckets?.some((b) => b.name === 'avatars')
|
||||
const bucketNames = new Set(buckets?.map((b) => b.name))
|
||||
|
||||
if (!exists) {
|
||||
if (!bucketNames.has('avatars')) {
|
||||
await supabase.storage.createBucket('avatars', {
|
||||
public: true,
|
||||
fileSizeLimit: 5 * 1024 * 1024, // 5MB
|
||||
@@ -20,5 +20,14 @@ export async function register() {
|
||||
})
|
||||
console.log('Created "avatars" storage bucket')
|
||||
}
|
||||
|
||||
if (!bucketNames.has('project-thumbnails')) {
|
||||
await supabase.storage.createBucket('project-thumbnails', {
|
||||
public: true,
|
||||
fileSizeLimit: 10 * 1024 * 1024, // 10MB (matches uploadProjectThumbnail validation)
|
||||
allowedMimeTypes: ['image/png'],
|
||||
})
|
||||
console.log('Created "project-thumbnails" storage bucket')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user