Back

Guidance needed for setting user profile picture

  • 0
  • Databases
  • Web
  • Users
  • Cloud
Kushl121
23 Feb, 2024, 19:36

Hey there, I could use a hand with something in the app I'm working on. Here, users can upload profile pictures, and I've set up a database ('userDatabase') to store userId ($id) and profileId (id of profile picture). The actual images are in a bucket called 'userBucket.'

The process to fetch the image feels a bit convoluted. We first get the profile picture ID from 'userDatabase' and then fetch the image. Also, .getFilePreview sometimes returns a URL even if the file doesn't exist, which messes things up.

Any ideas on simplifying this process or fixing the .getFilePreview issue? Thanks in advance!

TL;DR
Developers need help simplifying the process of setting user profile pictures as the current method involves fetching the image using profile picture IDs stored in 'userDatabase' and encountering issues with .getFilePreview returning URLs even if the file doesn't exist. One suggestion is to use the get file API call to ensure the file exists. If users can change their profile pictures, the current approach seems appropriate.
Kushl121
23 Feb, 2024, 19:37

Guidance needed for setting user profile picture

Steven
23 Feb, 2024, 19:57

We first get the profile picture ID from 'userDatabase' and then fetch the image.

if you're going to allow users to change their profile picture. this sounds like the right approach.

Steven
23 Feb, 2024, 19:57

Any ideas on simplifying this process or fixing the .getFilePreview issue?

If you want to make sure the file exists, you'd have to use the get file api call.

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more