supabase-community / storage-swift

Swift client library to interact with Supabase Storage
MIT License
26 stars 11 forks source link

Bad Request: while fetching all the files within a bucket #2

Closed rudrankriyam closed 3 years ago

rudrankriyam commented 3 years ago

Bug report

Describe the bug

Bad request error while fetching all the files within a bucket.

To Reproduce

After fetching the buckets successfully, the list method returns a bad request.

let client = SupabaseClient(supabaseUrl: "{ base url }", supabaseKey: "{ key }")

client.storage.listBuckets { result in
    switch result {
        case .success(let buckets):
            guard let bucket = buckets.first else { return }
            let file = client.storage.from(id: bucket.id)

            file.list { fileResult in
                switch fileResult {
                    case .success(let objects):
                        print(objects)
                    case .failure(let error):
                        print(error)
                }
            }
        case .failure(let error):
            print(error)
    }
}

Expected behaviour

After forking the package and printing the data, I found that the body is missing the prefix parameter -

body should have required property 'prefix'

Adding the prefix parameter worked, and it returned the files. However, there's no mention of the prefix in the JS docs.

CodeJonesW commented 3 years ago

I am having a similar issue when using from.remove() message: "body should have required property 'prefixes'", status: 400

How did you add this property using the client methods?

rudrankriyam commented 3 years ago

I forked the repo, added the package to my project and made the change manually. I couldn’t think of any alternate solutions

CodeJonesW commented 3 years ago

Thanks

rudrankriyam commented 3 years ago

Their C# and python clients do use prefixes in the body, so it looks like the documentation is outdated.

You can fork and make the necessary changes. I'll send a PR for this

rudrankriyam commented 3 years ago

Solved by #3