The logic is that a registered user on the Setting page must fill in the required fields and upload one or more images. The images are stored in Storage. After clicking on the Save button, all data is saved in the Profiles table.
To upload files I use Drag&Drop element. The avatarUrl variable with array type is created with it. In it I create the Storage | Upload a file workflow with the following settings:
But the URL is returned with âundefinedâ and this is the problem.
Next I wanted to change the avatarUrl variable so that the URL would be in Weweb and I could bind it to the avatar_url field and save it in the Profiles table
Have you tried to rename the picture to kira.jpg and fetch it as so? I have a feeling that this could be an issue of the case getting transformed for some weird reason. Have you tested other pictures/files?
From what I understand from your screenshot, you have an action 1 to upload a field, and an action 2 to get the public url of the uploaded file
But you are showing the binding on the action 2 and you bound the result of the action 2 to itself
Instead of binding result->publicurl you have to write âKira.pngâ, then execute the action, and in your action 3 you can use the result of action 2
Here youâre binding the result of action 2 in action 2
@Alexis Yes, youâre probably right. Only Iâm not quite sure how the result->publicurl binding place I should write âKira.pngâ in the URL? That URL that Supabase bucket provides I canât find. Where can it be located?
I think the path should be the name you used to upload the file
Here your item is inside avatars/Kira.jpg, but the action already target the bucket so Kira.jpg alone should be enough
If its for an user profile picture, you could name the img with the user id when you upload it, and so every time you need the public url you can use the user id for example, and it ensure one avatar will not erase another with the same name
I thought that the action âStorage | Retrieve public URLâ would return the public URL, but it doesnât?
I need to concatenate the URL and the image name, right?
In the third action I did the concatenation, i.e. I got the url and I saved it in a variable.
After clicking Save I save the URL to Supabase in the Profiles table.
This works, but if I need to upload a new image it doesnât work.
Using an id for a userâs image is a great idea, but I donât have much experience. Can you tell me how to assign an id to an image?
When you uploaded the file you choose the path, instead of using the name of the img, you could use the id of the current user (go to the user tab in explorer, you will have the user variable containing the id)
If you allow more than only jpg you may need to extract the extension to concatenate it (<user-id>+"."+<file-extension>).
Iâm not sure to understand what do you mean for the Retrieve public url, it should return you an url. What do you have in the result of the action when you use it ?
Some users reported a bug on the action where it return a wrong URL (a specific one that support transformation, like resize, but all supabase plan doesnât provide this service so itâs not working for everyone) but it always return something, the fix is in review and should be released soon
After the âStorage | Retrieve public URLâ action, I thought I could see and use it in Weweb. It appears in the logs, i.e. it is returned. I found the URL in the action results, but it was an error to use it (first message).
In your case you can link your âProfilesâ table to the Supabase âobjectâ table.
For each file uploaded in all your buckets, Supabase creates a record in a table called âobjectsâ.
To see it, go to Table Editor â schema: storage â objects.
Youâll see all your files. For each one of them, their is a uuid (first column). I would use that ID in the âProfilesâ table. For that, create a new columns in you âProfilesâ table and bind it to the "object table with a foreign key.
Then you can use the same kind of concatenate + lookup formulas combination to display your avatar.
However, WeWeb doesnât seem to allow us to lookup the storage schema.
So you may need to create a miror table like me.
In that case the function I gave you goes to Supabase â Database â Functions â Create a new function (type: trigger, security: definer). name it âhandle_new_imageâ
then, go to SQL Editor â New query:
create trigger handle_new_image
after insert on storage.objects for each row
execute function handle_new_image ();
After that, you can create a collection in Weweb and look it up with a formula.