What's the best way tu opload a file directly to Supabase storage?

remember that you have loops in workflows and you can mix and match them with javascript actions.
If it works for a single file use the code in a js action inside a loop in the workflow

1 Like

@visualdevs This thread ended awkwardly I thinkā€¦ :laughing: Was there some final Javascript code you needed up using to handle multiple files nicely?

The Supabase documention mentions not going over 6MB for the standard upload method

Thereā€™s some Resumable upload feature for larger files, which one does your method use? (Seems the simple upload method)

@dorilama :wave:

@Joyce Is there anything on the roadmap to add Supabase Storage natively in the plugin? To upload and retrieve/download files. Thanks! :pray:

1 Like

Welcome to the community :slight_smile:

to handle multiple files you need a loop, which you can create in the workflow. In the loop you can use the code to make the direct upload.
You can do it all in one javascript action but you need to handle correctly the async loop. If you go with the gpt path you can use the new copilot feature, ask Joyce how to get access.
Supabase announced the new resumable upload for large files yesterday, itā€™s in beta and not everybody has access to it right now.

1 Like

Yes! Itā€™s on our radar, currently under review but not yet prioritized

6 Likes

Blockquote
remember that you have loops in workflows and you can mix and match them with javascript actions.
If it works for a single file use the code in a js action inside a loop in the workflow

Thanks for this reminder. I really like how the JS stays very compartmentalized and the workflow loops make it more visual as to whatā€™s happening.

1 Like

Question. If a bad agent has a user account, wouldnā€™t they be able to see their authentication token as this is a front-end call, and just spam the userā€™s supabase storage?

See Network Restrictions

It doesnā€™t work for HTTPS requests to Storage, if you see the Limitations section at the bottom of the article. But definitely a good idea for general requests to the db

1 Like

Any updates on this?? Currently using google storage and supabase everything else.

1 Like

Yesssss. File storage plugins, including Supabase storage, are still under review (so canā€™t provide an ETA) but they are gaining ground in the roadmap :slight_smile:

4 Likes

Why not use a call to generate a signed upload URL for supabase? You make an authenticated call to get the URL, then use this URL for the upload. Supabase Javascript Client - Create signed upload URL

1 Like

Do you can show how to code that request? Because only with the following code itā€™s not possible to get the signed URL from Supabase. Would be great, if you can show the workflow. :slight_smile:

so important! :smiley: Are there any updates, when you have some good news for us?

wwLib.wwPlugins.supabaseAuth.publicInstance should have your supabase instance, so you can try await wwLib.wwPlugins.supabaseAuth.publicInstance.storage.from(...) (see here)

thx a lot for your replay! @dorilama

im struggling with this message nowā€¦ What iā€™am doing wrong?

the error is very clear: await can be used only in async functions

async function run(){
 await yourLogic()
}

Because the url is not created in a sync way you donā€™t want to do this in the code for the image source.
Itā€™s better that you do this in a workflow with a javascript action. In weweb javascript actions are wrapped inside async functions, so you can use the code directly. Add return data at the end so itā€™s available in the next action and assign the value to a weweb variable.

Hey @dorilama thx! The way to do this in a workflow worked very well! I got the presigned URL with expire token etc. You will see the rest in the screenshots (For other ones who need some inspirations :slight_smile: )


BildschirmĀ­foto 2023-06-27 um 23.14.33

My next question is how to get this code running without a workflow? I have a collection and every ā€œrowā€ should do this request of an unique image/signedURL. Can you show me how to do this? I searched a lot but got not helpful information :frowning:

My Collection:

Code:

const { data, error } = await wwLib.wwPlugins.supabaseAuth.publicInstance
   .storage
  .from('images')
  .createSignedUrl('test_image.png', 60);
  
return data

Thank you very much!!

you can use a for loop in the workflow and save the result in a object or an array.

Is that the common way to retrieve presigned urls from supabase storage? Because there are many posts here in the weweb community which struggle with uploading files to supabase. But nobody asked how to show the data/files :slight_smile:

I could also do the buckets of supabase as public, but then everybody with that link can see the sensitive data.

1 Like

Well, from your experience it looks like the binding for the image src is a sync function. You need to retrieve the url with an async function, therefore you canā€™t use the code directly in the binding because a promise is not a string. The next step is using workflow + variable. When you try that and discover something specific that you donā€™t like then you can decide if itā€™s the case to invest time and effort to find a different solution.
You may want to start another topic about this, it will make easier to search for it in the future by other users.

2 Likes