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?
@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.