Skip to content

Commit

Permalink
feat: upload profile picture in upload cropper
Browse files Browse the repository at this point in the history
  • Loading branch information
ruturajgole committed Oct 8, 2024
1 parent 1a71b8e commit 11ebd74
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions apps/main-app/components/UploadCropper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ onMounted(async () => {
async function uploadImage(blob: Blob) {
try {
const supabase = useSupabaseClient()
const result = await uploadFile(new File([blob], 'image.webp', { type: 'image/webp' }), {
bucket: props.bucket,
fileType: 'image',
Expand All @@ -145,6 +147,12 @@ async function uploadImage(blob: Blob) {
console.log(`Upload progress: ${progress}%`)
},
})
await supabase
.from('user_profiles')
.update({ avatar: result.publicUrl })
.eq('id', profile.value.id)
toast.success({
summary: 'Image uploaded',
message: 'Your image has been successfully uploaded and processed.',
Expand Down

0 comments on commit 11ebd74

Please sign in to comment.