https://supabase.com/ logo
Join DiscordCommunities
Powered by
# help
  • b

    Bryan K.

    10/09/2021, 6:58 PM
    I would probably make a database table with details about the files, including the information I would need about how to get it from the bucket. Then do all my queries on that table and when I need something from it, I have the info I need to use the download function to retrieve it from the bucket. You might want some other data about the files, like 'title', 'dimensions', 'author', etc. that you could store in the 'files' table.
  • b

    Bryan K.

    10/09/2021, 6:59 PM
    No, I think that the download function is for one file at a time.
  • b

    Bryan K.

    10/09/2021, 7:00 PM
    With your code, you could potentially download thousands of files in the list from the
    test/folder
    bucket.
  • n

    Nine

    10/09/2021, 7:01 PM
    I kinda would generate a specific folder always with 3 files
  • n

    Nine

    10/09/2021, 7:01 PM
    as in the storage I would generate new folders with three files each
  • n

    Nine

    10/09/2021, 7:02 PM
    and for a specific page I wanna pull the folder content for that specific page
  • n

    Nine

    10/09/2021, 7:02 PM
    and then do the magic 😄
  • b

    Bryan K.

    10/09/2021, 7:02 PM
    I see, yeah, I don't think you can chain the list and download functions.
  • n

    Nine

    10/09/2021, 7:02 PM
    but your table tip definitely sounds good cos nice data can be stored there
  • n

    Nine

    10/09/2021, 7:02 PM
    author, id and so on
  • b

    Bryan K.

    10/09/2021, 7:03 PM
    Yeah, I think that would be the fastest way to deal with the data in the bucket, because queries to the data table about the files in the bucket should be a LOT faster than queries to the buckets directly.
  • n

    Nine

    10/09/2021, 7:05 PM
    I see, as I am still new to the platform how would that essentially go, something like and idk if this is possible but
    Copy code
    js
    await supabase
      .from('cities')
      .insert([...list])
      .execute();
  • n

    Nine

    10/09/2021, 7:05 PM
    on a basic level I mean
  • b

    Bryan K.

    10/09/2021, 7:05 PM
    I think you could also do some cool stuff with triggers and functions, so that when a file record (row) in the files table was marked as 'deleted' you could trigger the storage function to delete that file from the bucket automatically. I haven't tried this myself, but it seems like a possibility.
  • n

    Nine

    10/09/2021, 7:05 PM
    yeah definitely
  • n

    Nine

    10/09/2021, 7:05 PM
    would it work tho as simple as the code I just sent above
  • b

    Bryan K.

    10/09/2021, 7:19 PM
    I'm not sure about that. You would need some way to add the record to the 'files' table and then upload the file to the bucket from somewhere. In either a single operation, or as a loop over each file added to the table. I don't know enough about your system or about Supabase (yet) to be of much more help. I am sure that this is a super-common thing to do. There is this example, https://github.com/supabase/supabase-js/tree/master/example/next-storage where they upload an Avatar file and update the 'Profile' record 'avatar_url' for the Profile image. See https://github.com/supabase/supabase-js/blob/master/example/next-storage/components/Account.tsx#L30
  • b

    Bryan K.

    10/09/2021, 7:23 PM
    If those files in the bucket were related to some other record, like in the example the avatar file is related to a profile record, then you could also store the array of bucket file references in the record they relate to.
  • b

    Bryan K.

    10/09/2021, 7:24 PM
    Like you might have a 'product' record, with an array of product 'images' that refer to files in the bucket folder for that product.
  • b

    Bryan K.

    10/09/2021, 7:26 PM
    @User check this out. https://github.com/supabase/supabase/discussions/3025
  • n

    Nine

    10/09/2021, 7:31 PM
    Thanks a lot @User you gave me a lot of great infos I will dive deep into these and build my understanding of the matter
  • b

    Bryan K.

    10/09/2021, 7:32 PM
    Thank you and please ping me here once you figure it out. I'm new to Supabase too, so I will appreciate learning from you.
  • n

    Nine

    10/09/2021, 7:34 PM
    Will definitely do, I will have to turn all these infos into code tomorrow 😄 and you have brought me more understanding to the matter
  • l

    lulato

    10/09/2021, 8:38 PM
    Hey guys! I am new to Postgress, I just enabled
    Row Level Security
    to by Table and I added a policy that only 'authenticated' users can insert, but its not working. Do i need pass an argument on my
    insert
    code block, how does the system know if im authenticated ?
  • g

    garyaustin

    10/09/2021, 9:04 PM
    You might want to check the error in the network response, but also make sure you have a read policy set as insert also does a read.
  • v

    Village

    10/09/2021, 10:14 PM
    How can I set up SSL with self-hosted supabase?
  • i

    iTzMurtaja

    10/09/2021, 10:28 PM
    Hello, how can I move a project to an organization?
  • d

    Dots

    10/09/2021, 10:30 PM
    @User you got a second?
  • d

    derschuft

    10/09/2021, 10:32 PM
    Hi guys, while testing the auth API with Postman i stumbled upon a problem with the /token endpoint - it responds with { "code": 400, "msg": "Could not read password grant params: EOF" } I have the grant_type and the credentials set in the request body and the content-type header on 'application/x-www-form-urlencoded' but the error persists - any ideas on what my mistake is? i could not find much on this error by myself despite a React Native problem...
  • d

    Dots

    10/10/2021, 2:25 AM
    @User buckets for our site have been down for 5 hours =/
1...105106107...316Latest