1

I have made an app that requires login authorization, and I want each user who has signed up for the app to have their own folder in the firebase storage. That way, all the data that gets passed to firebase is organized in separate folders for each user; keeping everything organized and the data easily accessible. I am wondering how to do this but am lost. I currently have firebase set up for my app but am struggling to figure this part out.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Austin
  • 37
  • 4
  • Have you checked [How to create a folder in Firebase storage?](https://stackoverflow.com/questions/37664385/how-to-create-a-folder-in-firebase-storage). Using the method in that answer, you just need to set user's UID as folder name. – Dharmaraj Sep 14 '21 at 18:14
  • @Dharmaraj thanks for the response, I will look into this! – Austin Sep 14 '21 at 18:23

1 Answers1

1

To allow users to only read/write their own files, have a look at the section on content-owner only access in the documentation on security rules.

to upload files to a user-specific folder, start by setting up a reference to the user folder:

let storageRef = storage.reference()

if Auth.auth().currentUser != nil {
  let uid = Auth.auth().currentUser.uid

  let userRef = storageRef.child()
  ...

And then follow the rest of the documentation on uploading files.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807