Swift client library to interact with Supabase Storage

Overview

storage-swift

Swift Client library to interact with Supabase Storage.

Sponsors

We are building the features of Firebase using enterprise-grade, open source products. We support existing communities wherever possible, and if the products don’t exist we build them and open source them ourselves. Thanks to these sponsors who are making the OSS ecosystem better for everyone.

New Sponsor

Comments
  • Bad Request: while fetching all the files within a bucket

    Bad Request: while fetching all the files within a bucket

    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.

    bug 
    opened by rudrankriyam 5
  • Add public config

    Add public config

    What kind of change does this PR introduce?

    • Adds a StorageApiConfig struct with the public properties
      • url
      • headers
    • Modifies StorageApi, StorageBucketApi and SupabaaseStorageClient to use the new config object.
    • Adds an initializer to each above class to initialize directly with a config object.

    What is the current behavior?

    Config variables (url, headers) aren't available to a public API. This leads to problems when dealing with auth changes and other changing things that may need to change headers after initalization.

    What is the new behavior?

    Config can be changed in various ways

    // Add an authorization header
    client.config.headers["Authorization"] = "Bearer: 1234"
    
    // Change the base url
    client.config.url = "app.supabase.io"
    
    // Remove an authorization header
    client.config.headers["Authorization"] = nil
    
    // Initialize a client using a config object
    let config = StorageApiConfig(url: "app.supabase.io", headers: [:])
    
    let client = SupabaseStorageClient(config)
    

    Other notes

    This is also a modification related to the changes on this PR on postgrest-swift.

    opened by thecoolwinter 2
  • Implement Codable

    Implement Codable

    What kind of change does this PR introduce?

    Bug fix, feature, docs update, ...

    What is the current behavior?

    • fetch return-type dependant on response
    • data is then decoded with JSONSerialization and instances created manually

    What is the new behavior?

    • fetch returns response data directly, but will still attempt to decode and throw an error if the status code is not 2XX
    • data is decoded using JSONDecoder & Codable models

    Additional context

    • wrote test cases for all File & Bucket Api Operations
    • refactored StorageApis to use url instead of string when building endpoint urls
    • added some documentation to Api methods
    opened by NoahKamara 1
  • Make StorageError initializer public

    Make StorageError initializer public

    I made the initializer from StorageError public so it can be used from outside of the package. This allows developers to make wrappers over certain functions and they can return StorageError as result if needed.

    For example, I've created this extension over StorageFileApi and I would like to return StorageError if I cannot convert UIImage to Data image

    opened by AngCosmin 1
  • Implement StorageHTTPClient and remove non-concurrency method versions

    Implement StorageHTTPClient and remove non-concurrency method versions

    What kind of change does this PR introduce?

    Bug fix, feature, docs update, ...

    What is the current behavior?

    Please link any relevant issues here.

    What is the new behavior?

    Feel free to include screenshots if it includes visual changes.

    Additional context

    Add any other context or screenshots.

    opened by grsouza 0
  • Import FoundationNetworking when needed.

    Import FoundationNetworking when needed.

    Add FoundationNetworking if available. This is allowing Linux platforms to compile the framework, since the migration of URL-related function to the FoundationNetworking framework.

    opened by mbarnach 0
  • Implement Codable

    Implement Codable

    What kind of change does this PR introduce?

    • Bug fix

    What is the current behavior?

    • fetch return-type dependant on response
    • data is then decoded with JSONSerialization and instances created manually

    What is the new behavior?

    • fetch returns response data directly, but will still attempt to decode and throw an error if the status code is not 2XX
    • data is decoded using JSONDecoder & Codable models

    Additional context

    • also implemented updateBucket & updated createBucket, adding isPublic option
    • wrote test cases for all File & Bucket Api Operations
    • refactored StorageApis to use url instead of string when building endpoint urls
    • added some documentation to Api methods
    opened by NoahKamara 0
  • JSON decoding issues

    JSON decoding issues

    Bug report

    I've noticed that JSON decoding has some issues (missing keys, optionals not handled) and that you're not using Codable to decode. Is there a particular reason for that?

    As far as I'm aware, Codable is available on linux too according to this PR

    The Bucket Model for example is almost entirely optional, which is not handled (maybe due to code generation from javascript?)

    If there is no reason against implementation with Codable, I'd be up to doing that :)

    bug 
    opened by NoahKamara 1
Releases(0.1.0)
  • 0.1.0(Oct 25, 2022)

    What's Changed

    • Implement StorageHTTPClient and remove non-concurrency method versions by @grsouza in https://github.com/supabase-community/storage-swift/pull/6

    New Contributors

    • @grsouza made their first contribution in https://github.com/supabase-community/storage-swift/pull/6

    Full Changelog: https://github.com/supabase-community/storage-swift/compare/0.0.2...0.1.0

    Source code(tar.gz)
    Source code(zip)
  • 0.0.2(May 14, 2022)

    What's Changed

    • Import FoundationNetworking when needed. by @mbarnach in https://github.com/supabase-community/storage-swift/pull/4
    • Make StorageError initializer public by @AngCosmin in https://github.com/supabase-community/storage-swift/pull/5

    New Contributors

    • @mbarnach made their first contribution in https://github.com/supabase-community/storage-swift/pull/4
    • @AngCosmin made their first contribution in https://github.com/supabase-community/storage-swift/pull/5

    Full Changelog: https://github.com/supabase-community/storage-swift/compare/0.0.1...0.0.2

    Source code(tar.gz)
    Source code(zip)
  • 0.0.1(Feb 22, 2022)

    What's Changed

    • Replace path with prefix in list method of StorageFileApi by @rudrankriyam in https://github.com/supabase-community/storage-swift/pull/3

    New Contributors

    • @rudrankriyam made their first contribution in https://github.com/supabase-community/storage-swift/pull/3

    Full Changelog: https://github.com/supabase-community/storage-swift/commits/0.0.1

    Source code(tar.gz)
    Source code(zip)
Owner
Supabase Community
Supabase Community
This To-Do app was developed using Swift and SwiftUI and works on iOS, MacOS (Apple Silicon) and WatchOS. The tasks are kept on storage even when the app is restarted.

ToDo-SwiftUI This app has a lot of sentimental value for me, given that it helped me a lot to understand the process of doing an iOS app and became th

Augusto Galindo Ali 6 Jul 12, 2022
Swift iPhone and iPad Client for Polls API, using Hyperdrive API client

Polls Client This is a Swift iPhone and iPad client for the Polls API - a simple application allowing users to view polls and vote in them. Polls is a

Apiary 34 Jul 15, 2022
A swift client library for GoTrue.

gotrue-swift Swift client for the GoTrue API. Using The usage should be the same as gotrue-js except: Oauth2: signIn with oauth2 provider only return

Supabase 23 Jan 7, 2023
A swift client library for GoTrue.

gotrue-swift Swift client for the GoTrue API. Using The usage should be the same as gotrue-js except: Oauth2: signIn with oauth2 provider only return

Supabase Community 23 Jan 7, 2023
Client library for making in-app purchases on iOS and macOS Automattic apps

MobilePayKit Client library for making in-app purchases on iOS and macOS Automattic apps Introduction MobilePayKit is a client library for making in-a

Automattic 8 Oct 20, 2022
A small SwiftUI based chat client for IRC, using swift-nio-irc

NeoIRC A simple Internet Relay Chat client implemented using SwiftNIO and SwiftUI. Inspired by: For maximum NIO someone (I’m tempted) should adopt NIO

The Noze Consortium 18 Jun 22, 2022
Seaglass is a truly native macOS client for Matrix. It is written in Swift and uses the Cocoa user interface framework.

Seaglass is a truly native macOS client for Matrix. It is written in Swift and uses the Cocoa user interface framework.

null 1 Jan 17, 2022
iOS client for Giphy written in Swift with ReactiveCocoa

Giraffe iOS client for Giphy written in Swift with ReactiveCocoa Requirements iOS 10.0 Beta Xcode 8 Beta 2 Swift 2.3 Carthage Why S

Yevhen Dubinin 43 Feb 10, 2022
A completely native Discord client for macOS built 100% in Swift and SwiftUI

Swiftcord A completely native Discord client for macOS built 100% in Swift and SwiftUI This project aims to create a fully functional native Discord c

CryptoAlgo-Dev 1.1k Jan 9, 2023
A cross-platform Reddit client built in SwiftUI

A cross-platform Reddit client created in SwiftUI. Get the Public Beta Note: This project is far from complete. It still lacks many features of your t

Carson Katri 1.2k Dec 25, 2022
An open-source SwiftUI Stack Overflow client

StackOv A SwiftUI Stackoverflow client We are currently in the developing process of the next version of StackOv app. The demo version of StackOv is a

Surf 235 Dec 17, 2022
Tutorial GraphQL + Node Express + MySQL, and sample for Android / iOS client

GraphQL-tutorial Tutorial for GraphQL + Node Express + MySQL, and sample for Android / iOS client Blog NeoRoman's GraphQL-tutorial (Korean) Materials

Henry Kim 4 Oct 20, 2022
Native Jellyfin Client for iOS and tvOS

Swiftfin Swiftfin is a modern client for the Jellyfin media server. Redesigned in Swift to maximize direct play with the power of VLC and look native

Jellyfin 1.1k Jan 6, 2023
Basic Unsplash client for iOS made with SwiftUI (beta).

PapersSwiftUI Basic Unsplash client for iOS made with SwiftUI (beta). Note SwiftUI is still in beta and I'm also still learning how it works. To-Do: P

Don 19 Dec 17, 2022
💥 a modern xkcd iOS client

XKCDY / app This is the source code of the XKCDY app. I built this app primarily as a way to learn Swift and SwiftUI. Because I was learning as I buil

null 32 Oct 30, 2022
A xkcd client written in SwiftUI.

xkcd A xkcd client written in SwiftUI. Architechture: Tried to use MVVM but with CoreData... If you know, you know. Features: Supports Dark/Light mode

Sina Rabiei 10 Oct 21, 2022
The alternative last.fm client for iOS made with SwiftUI

first.fm - The alternative last.fm client for iOS (it's actually not available on the App Store... yet) Features Your profile (top artists, tracks and

Stanislas 22 Aug 22, 2022
Client that retrieves specific information about stocks.

Client that retrieves specific information about stocks. This app is used as training to develop design pattern skills, in this case: the Coordinator Pattern

Marco Marinò 1 Apr 26, 2022
Tanukis-Stash - Open source e621 client for iOS built with SwiftUI

The Tanuki's Stash The worlds first e621 client for iOS, iPadOS, and macOS built

Jay 3 Jul 29, 2022