Back

Function return image

  • 0
  • Functions
Mickaël LT
16 Mar, 2023, 22:12

Hi,

Is it possible for a function (or webhook?) to return a file ? I want to return user profile image only from an id of a user ?

TL;DR
The user wants to know if it's possible for a function or webhook to return a file, specifically a user's profile image based on their ID. The suggestion is to store the images in a profile images bucket with matching IDs. If the image URL is known, the image can be easily fetched. If the image is stored as a public file, it can be fetched using the storage API. If the image is not public, the user may need to make the profile images public or try base64 encoding it if the file is small.
Drake
16 Mar, 2023, 22:27

If it's small, you can try to base64 encode it

Drake
16 Mar, 2023, 22:27

Otherwise, you may need to make profile images public

Mickaël LT
16 Mar, 2023, 22:29

And if it is public, how can I achieve this ?

Drake
16 Mar, 2023, 22:30

if it's public, you can use the storage api to fetch it 🧐

Drake
16 Mar, 2023, 22:30

assuming you're storing it in appwrite...

Mickaël LT
16 Mar, 2023, 22:32

But If I don't have the url of the image ? link of the profile picture is in the collection of my user, so I need to fetch first user collection, get the link and then get image from storage

Drake
16 Mar, 2023, 22:33

i would store the images in a profile images bucket where the ID matches the user ID. then you can easily get the file with the user id

Mickaël LT
16 Mar, 2023, 22:34

hum ok, I see, good idea 👌

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