can i use supabase filesystem with a nosql database?
can i use supabase filesystem with a nosql database?
93 Replies
Hi :vmathi: Do you mean the storage when saying "filesystem"?
hey, yes i do
i ve got a project and i need storage but im using mongodb
You can use the Supabase storage, but i think you would need to serve files from a server
Supabase's storage doesn't give you a link directly, so you need to generate it. Example here: https://supabase.com/docs/guides/with-react#create-an-upload-widget
so when i get the route of the image in the user device i need to send it to the backend and then store it there?
thanks
Basically your website will request the url of the file to a specific server, which will be connected to Supabase and generate it. Here is a simple example for an avatar file (from the link above):
You don't need a server if you're using Supabase on a client side tho
oh ok ok, and is there any documentation to use supabase on the server side?
To make it simple, if you only want a "micro service" for storage, you will need a server to make the bridge between Supabase files and your clients/platforms. Otherwise, you can do it directly using Supabase SDKs 😄
yeah... but i already have the server coded
SDK + service role basically. It's the same stuff than the client side
oh ok so basically doing the same as the front end but sending the url to the server and doing it from the server, thanks man
one more question, how do i create a bucket, it says i need postgresql
Supabase uses postgres under the hood
https://supabase.com/docs/reference/javascript/storage-createbucket It should not be harder than that. Do you have specific errors?
i dont know, im kind of lost because i ve never used storage and im using mongodb
This should be the architecture you have

Supabase and Mongo should not interact directly. The server should do the job
oh ok ok thanks and sorry for being so annoying
No problem! Don't hesitate to ping me again if need help :p
hey man, just started reading the docs and im not sure if i'm getting it, i think i have to follow this steps:
1 create a project and a bucket
2 create client with the supabase javascript module, even though im going to use it on my server, with the api keys they gave me
3 post the route of the file in the user's device to the server
4 upload the file to storage
5 whenever i want to, send request to backend and download images
i dont know, is this everything i have to do? do i have to do something with the database? anyways thanks
btw im using react native(expo) and node js
Yeah it sounds good to me
aight aight cool
hey, im getting this error using supabase and expo:
This is my code, also i dont know if im uploading the image the right way:
client.js:
upload image:
pick image:
Are you getting this error when you start your react native app? @LeBruno James
I think there is all that stuff missing, creating this issue:
To install
To change
oh, okay I'll do that, i though that was for authentication, that's why I didn't write it
thanks
i love you man it worked
i mean it isnt uploading but it stopped showing me that error
Check if the
path
variable is right, and you're uploading the right fileits giving me this warn:
but the path and file are right
this is my code:
this is the code for picking images
You can't upload a formData, it's not supported I think. You only can upload
File
So basically you should upload result.assets[0]
`
its uploading the form data
in the supabase website
but im gonna try with that
thanks
Nevermind, i was reading the Svelte guide 😂
Do you have any error message?
no, just that
oh lol
its not working either
with result.assets[0]
hmmm
Can you have a look in your Supabase dashboard? There is a log tab where you can inspect what is happening. It could help on the issue
By the way, do we know if it's the
supabase.storage.from('avatars').upload
method which throws the error, or is it the DocumentPicker.pickSingle
method?its the upload, but im using expo imagePicker
is that a problem?
that im using expo image picker
OOOH
Wait
I maybe found the issue
Just here:
formData.append("image", image);
if you take a look in the expo example, it's formData.append("file", image);
oh oh oh, im gonna try that
still not working 😓
:/
I think it's the best shot we have
how do i that

this?
oh wait i have some logs
cool
You should have some logs in the "Storage" tab on the left
Metadata
here
content-type is multipart/form-data;
new row violates row-level security policy for table \"objects\"
looks like we got the erroryeah
i dont have anything set up in the database
do i have to do somethin
with the database?
like the schema
?
By default, a lot of things are public with Supabase (your tables). To restrict the access, there is a RLS system. Looks like the storage system is restricted by default, meaning you can't have access directly.
You can either setup your own rule, or make it public access
oh okay, so how do i make it publlic
It's not really complicated. I dropped you the link above, there is some examples. You simply execute the code in the SQL editor of the Supabase dashboard
A total access would be:
oh ok thanks a lot, lets see if it works
Of course, your bucket name is not "public", so you will have to change the name to your bucket name

i need to run it here?
Yep
ok i executed it lets see
awww cmon man
Not working? :/
no 😦
Did you change the name of the bucket? 🤔
yeah
create policy "Public Access"
on storage.objects for select
using ( bucket_id = 'images' );
like this right?
Yep
Do we have anything in logs?
nothing new
im gonna go and come back tomorrow with a clear mind
thanks bye
If you want, we could go in voice chat tomorrow and try to solve that?
umm id rather talk here, cause my english isnt too good, im spanish, and im 14 so my parents are home
and I'm embarrassed to speak in front of them lol sorry
and I'm embarrassed to speak in front of them lol sorry
No problem ahah, i was thinking about a screen sharing, but that's okay!
oh i could share screen
We can try that tomorrow :p
bro i stopped getting the warn but got a new error in the console
It still says there is an issue with RLS, no idea why
yeah, thats what i found too
but idk what to do

should i do this?
i did it
its still not working
its the rls but idk whaaaaatttt 😩
Try to login to your database using pg_dump and the connection string of your instance, and do
\d pg_policy
to list all existing policies for your database
It could be an issue from another policyim going to sleep ill try that tmr
its 00:50
Ahah same here :p
where do i do this?
In the console directly. When you're connected to your database using pg_dump, you can simply paste this special command inside
i think i found out whats wrong
GitHub
Can I use only Supabase's storage solution? · Discussion #6097 · su...
I assume this is the case, but I have to make sure (completely new to supabase/PostgreSQL). Am I able to use Supabase's storage solution and utilize all its security features without using ...
i already have authentication, i coded it myself, so idk if i should use supabase auth
holy sh*t bro @Olyno i fixed it
it uploaded
im so happy

i think the image is wrong format but it worked
Wait, how?
How did you manage to fix that?!
i did it
its working
all of it
so what i did
is run this `
in the sql editor
and it wasnnt posting as images then, but i managed to solve it by getting the base 64 of the image and decoding it to an array buffer
thanks a lot man you were very helpful 🤝
so i have a question, when i want to display the image, should i just display it with the link, or download the image or something?
Oooooh wait, i'm just dumb. The RLS i sent you before was for
select
, not insert
😂
It should be as link for sure :plmaoo
oh okay, so download is just if you want the image in your device?
The download method is to get the file. It's like downloading the file in cache. From this file, you need a link to display it :p
ohh okay thanks man
You did all the thing 😅 Thanks to you to show me my mistake 😄
lol well it was very nice talking to you, cya
btw is the supabase website working for you?

Yep, working on my side
idk why
do you use node js?
whats your tech stack
Yeah, Node mainly
im getting this error all the time
and it sometimes stop
oh cool
look
No idea xD
its so annoying