236
Views
5
Comments
How to upload image for user profile image?
Application Type
Reactive

Hi there,

For our application (Reactive using ODC) I want users to upload an image themselves. In the user entity there's only the photo url attribute, which I also want to use. But if I want to store the image in the database, how can I create a link easily to retrieve that image?

I have already an entity where files can be stored in binary data.

I already checked some other posts about this, but it's not very clear to me. 



2023-12-16 19-57-03
Sanjay Kushwah

Hi @Eric van Heesen,

When you Uploading Image into your second Entity which is storing your Image as Binary, after create record in this entity 

Retrieve the generated imageId from the response.

Update the photoUrl attribute of the User entity with the following URL format:

/file/image/{imageId}

Note: check the URL format path as per your directories.


Thanks,

Sanjay Kushwah

UserImage.jpg
Eric van Heesen

Hi Sanjay,

This seems a good solution. However, I'm figuring out which exact url path I need to use.

You mentioned as an example "/file/image/{imageid}". But is this the path of the entities?

Let's say the binary file is stored in the entity "File", using the attribute Image. What would be the path in that case?

2023-12-16 19-57-03
Sanjay Kushwah

Hello @Eric van Heesen,

If you want to store image as binary not in any folder then you can not access by URL directly becuase that time you don't have any path of image,

But still if you really need to access your image via URL then you can definately get it by URL 

Just Expose a GET API to get your IMAGE /file/image/{imageid}   where {Imageid} is your Image entitiy Id Inside your API fetch image Using This Imageid  and send to response.

For Example: 

file/image/{12}

file/image/{13}

where 12 , 13 are your Image Entity Row ID

when you hit this URL you will get your Binary Image form Entity.

Thanks,

Sanjay Kushwah  

2024-02-16 07-43-18
Amit Verma

Hi @Eric van Heesen ,

Check this thread. I think there is other similar questions on the forum to help you :)

https://www.outsystems.com/forums/discussion/65244/how-to-create-a-user-profile-page-and-allow-them-to-manage-theirr-profile/

Thanks,

Amit


2024-07-05 14-16-55
Daniël Kuhlmann
 
MVP

Hello Eric,

Although ODC already has server actions to get the user profile and update the user profile, which also has the PhotoURL as you mentioned, you cannot really use them. And you might as, why? The reason is that the way ODC uses the User entity is different from in O11.

The user entity is used as a cache of logged-in users not so much as a metadata entity will all the user data.

So if you want to have complete user management, where also users can update their profile, you will require to define additional entities that have a relationship with the User entity, and then adjust the UpdateUserProfile and Layout for the user to reflect those changes.

Note that OutSystems will release most likely the public user management API, which might include the features that you would currently be required to develop yourself.

Regards,

Daniel


Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.