const {
data: { user },
error,
} = await supabase.auth.getUser(accessToken)
// some additional checks here....
for (let file of files) {
if (file instanceof File) {
// Create a unique file path, e.g., using user ID and timestamp
const filePath = `${user.id}/${Date.now()}-${file.name}`
const { error } = await supabase.storage.from('photos').upload(filePath, file, {
cacheControl: '3600',
upsert: false,
})
console.log(error)
if (error)
return new Response(
JSON.stringify({
error: 'Something went wrong with picture upload',
}),
{ status: 500 }
)
} else {
return new Response(
JSON.stringify({ error: `file upload failed for user-${user.id}/${Date.now()}` }),
{ status: 500 }
)
}
}
const {
data: { user },
error,
} = await supabase.auth.getUser(accessToken)
// some additional checks here....
for (let file of files) {
if (file instanceof File) {
// Create a unique file path, e.g., using user ID and timestamp
const filePath = `${user.id}/${Date.now()}-${file.name}`
const { error } = await supabase.storage.from('photos').upload(filePath, file, {
cacheControl: '3600',
upsert: false,
})
console.log(error)
if (error)
return new Response(
JSON.stringify({
error: 'Something went wrong with picture upload',
}),
{ status: 500 }
)
} else {
return new Response(
JSON.stringify({ error: `file upload failed for user-${user.id}/${Date.now()}` }),
{ status: 500 }
)
}
}