Skip to content

Add "recursive listing" option to files List function #18

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
HighPriest opened this issue Aug 20, 2024 · 2 comments
Open

Add "recursive listing" option to files List function #18

HighPriest opened this issue Aug 20, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@HighPriest
Copy link

Feature request

Problem

I would like to store two types of configuration files, accessible from one bucket, through one auth key.
It would also be convenient for a deeper folder structure to exist.

Describe the solution

When I "List" all files in a bucket, or directory. I would like to have an option for all the files in sub-directories to also be listed, with their full & relative paths. It would be nice if there was an endpoint we could query directly for data already structured, rather than manually querying every path, which is not a file.

Describe alternatives you've considered

I can make a direct query for contents of the objects table in the Postgres database. But this is neither convenient, nor safe (or easy to make safe).

@HighPriest HighPriest added the enhancement New feature or request label Aug 20, 2024
@HighPriest
Copy link
Author

FYI.
I use this little monster to get ALL the files in a bucket:

        public void ListAllFiles()
        {
            public_files = new List<Supabase.Storage.FileObject>();

            foreach (Supabase.Storage.FileObject _file in Task.Run(() => supabase.Storage.From("Public").List()).GetAwaiter().GetResult())
            {
                recursiveSupabaseFileListing(_file, "");
            }
            foreach (var file in public_files)
            {
                Debug.WriteLine("File Name: " + file.Name);
            }
            Debug.WriteLine("FilesListed: " + status);
        }


        public void recursiveSupabaseFileListing(FileObject file, string path)
        {
            string _path = path.IsNullOrEmpty() ? file.Name : String.Join("/", path, file.Name);

            if (!file.IsFolder)
            {
                file.Name = _path;
                public_files.Add(file);
                return;
            }

            var files = Task.Run(() => supabase.Storage.From("Public").List(path: _path)).GetAwaiter().GetResult();

            Debug.WriteLine(_path);

            foreach (Supabase.Storage.FileObject _files in files)
            {
                recursiveSupabaseFileListing(_files, _path);
            }
        }

@acupofjose
Copy link
Contributor

Thanks for the issue @HighPriest - this doesn't look like it's supported from the Supabase Storage server as an endpoint, nor is it implemented in the JS client. I think you should open an issue up on the server repo to have them implement an endpoint rather than us hacking together a solution on the client!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants