Back

[SOLVED] Managing uploaded files per user in Appwrite Storage

  • 0
  • Flutter
  • Storage
Faisal7
30 Jun, 2023, 09:36

I am trying to manage the user generated content such as images, videos etc in my appwrite storage so by every user registration i create a bucket for that user and from this point how can i manage the user data i mean in a normal scenario i would have different folders for each like images, videos etc how it works in appwrite sorage i can just have buckets and inside it all the file so i dont see the opportunity to do it folder wise so how can i manage all the stuffs per user.

TL;DR
You can create a separate bucket for each user during registration using cloud functions. Then, you can manage that storage bucket for individual users' files. You can also add a unique identifiable key or metadata to the files to differentiate them. Use the ListFiles method to retrieve all the files of a specific user.
joeyouss
30 Jun, 2023, 11:41

Hi

joeyouss
30 Jun, 2023, 11:44

You can try creating separate buckets during registration ( a suggestion) and have internal naming system defined by you for your own file structure - like adding prefixes for the files uploaded and/or adding a unique identifiable key to different users. You can use our https://appwrite.io/docs/client/storage?sdk=web-default#storageListFiles for listing

Faisal7
30 Jun, 2023, 12:53

by adding a adding a unique identifiable key you mean while uploading the file i should also set some metadata to it and the search through a specific metadata?

Asutosh
30 Jun, 2023, 15:37

In order to store files of a particular user you can create storage bucket for every user while your user registration using cloud functions and then you can manage that storage bucket for individual users files

Faisal7
30 Jun, 2023, 21:34

First i need then to set the bucket id the user id? And second how would then the file name structure of all different user contents look like?

Asutosh
1 Jul, 2023, 05:24

Yes you can set the user id of a user as their storage bucket id and add all files of that user to that particular storage bucket. And to get all of the files of a user use the ListFiles method

Asutosh
1 Jul, 2023, 05:24

Hope this answers your question

Faisal7
1 Jul, 2023, 10:15

yes thank you alot @Asutosh.

Faisal7
1 Jul, 2023, 10:15

[SOLVED] Managing uploaded files per user in Appwrite Storage

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more