Retreiving URL from Supabase Bucket

Hey folks,

I’m currently working on a site where users are able to upload videos. Right now, with the upload workflow the user is able to upload the file to a bucket in Supabase and then simultaneously create a row in a table in Supabase. I’m trying to add an action in that flow that inserts the url from the bucket into the corresponding row in the table.

I see that similar question has been asked in the past, so apologies if I’m re asking. But, my questions would be

  • broadly speaking, is this workflow the correct way to go? (upload file to supabase bucket, simultaneously create row in table with metadata that I want for that user, action to retrieve url from bucket then insert into table for user)
  • How do I retreive that URL from the Supabase bucket? I’ve played around with some of the code snippets that I’ve seen here/on Supabase’s website. Alas, I am no coder and havent gotten that to work in the slightest.

thanks a million in advance for any help!

Welcome, @ace !

First off, is the Supabase bucket public?
If yes, I would store the URL. If no, I would store the path.

Here I have a Upload, Get a Public URL then Update row (or insert row? depending on what you do)

If it was a non-public bucket I would use something like this:
Upload, update row with path; to fetch, get signed URL of row and return the signed URL/change a variable.

thanks @Kawwl ! Yes I do have this workflow setup.

The bucket is public. When I go to ‘storage | retrieve public URL’ there isn’t a way for me to select that information from any type of Supabase bucket item. Not sure if there should be; I only have the attached option

What you are looking for is here:
Once you have run the get public URL it will appear in the workflow tab. Then you can get the url value :slight_smile:

I think we’re getting closer! But still a bit confused. I made a loom linked here Understanding File Upload Process 👩‍💻 | Loom

thanks again for all the help!

No worries!
You can think about path as folder structure, and you can create it as you see fit. ie:

bucket/folder/new_folder/filename.jpeg

In your workflow, when you want to get public URL you are sending the path to the file:
“bucketname/folder/filename”.

Here, you want to select fullPath. Once this runs, it will get the Public URL.
In the next step, you want to go back to Workflow actions, and there it will have returned the URL. (Action 2)

This isn’t the best way, because it could break the sync and you could have orphan images, or rows with corrupted images links. What you probably should do is create a trigger on the image uploaded.
E.g

CREATE TRIGGER Insertar_oaprecios
AFTER UPDATE ON storage.objects
FOR EACH row
EXECUTE FUNCTION cargar_oaprecios_desde_json();

Yeah, broberto is right. :sweat_smile: I sent you on a non-optimal path.
But its a simple one.

Thanks @Broberto ! that may be a step 2 for me once I figure out this first way first (still learning lol)

@Kawwl that kinda worked? So now I get a url inserted into my table, but when I click on that url i get a page like this

I’m also noticing that the url for a working link from the bucket–one that I’ve manually pasted into the table here at the top–looks different?

@ace The top one looks like a signed URL. Are you sure your bucket is public? :slight_smile:
See if you can go the storage bucket and get the public URL, should be the same.

@Kawwl Yup nearly positive its public
Screenshot 2024-10-22 at 9.14.48 AM

when I go into the bucket and grab the url for that video I just uploaded though, it gives me back a URL like the one on the top of my previous comment (A signed URL yes?)