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
Supabase
A type-safe, fluent Swift library for working with Core Data

Core Data Query Interface (CDQI) is a type-safe, fluent, intuitive library for working with Core Data in Swift. CDQI tremendously reduces the amount o

null 31 Oct 26, 2022
A type-safe, fluent Swift library for working with Core Data

Core Data Query Interface (CDQI) is a type-safe, fluent, intuitive library for working with Core Data in Swift. CDQI tremendously reduces the amount o

null 31 Oct 26, 2022
Super awesome Swift minion for Core Data (iOS, macOS, tvOS)

⚠️ Since this repository is going to be archived soon, I suggest migrating to NSPersistentContainer instead (available since iOS 10). For other conven

Marko Tadić 306 Sep 23, 2022
A powerful and elegant Core Data framework for Swift.

A powerful and elegant Core Data framework for Swift. Usage Beta version. New docs soon... Simple do that: let query = persistentContainer.viewContext

null 782 Nov 6, 2022
CloudCore is a framework that manages syncing between iCloud (CloudKit) and Core Data written on native Swift.

CloudCore CloudCore is a framework that manages syncing between iCloud (CloudKit) and Core Data written on native Swift. Features Leveraging NSPersist

deeje cooley 123 Dec 31, 2022
Unleashing the real power of Core Data with the elegance and safety of Swift

Unleashing the real power of Core Data with the elegance and safety of Swift Dependency managers Contact Swift 5.4: iOS 11+ / macOS 10.13+ / watchOS 4

John Estropia 3.7k Jan 9, 2023
CoreData based Swift ORM

Swift ORM Features Pure swift objects - no more subclasses of NSManagedObject Extensible attribute system - store any type in CoreData storage by impl

Prisma Labs 89 Dec 29, 2022
HitList is a Swift App shows the implementation of Core Data.

HitList HitList is a Swift App shows the implementation of Core Data. It is the demo app of Ray Wenderlich's tech blog. For details please reference G

Kushal Shingote 2 Dec 9, 2022
JSON to Core Data and back. Swift Core Data Sync.

Notice: Sync was supported from it's creation back in 2014 until March 2021 Moving forward I won't be able to support this project since I'm no longer

Nes 2.5k Dec 31, 2022
A Swift framework that wraps CoreData, hides context complexity, and helps facilitate best practices.

Cadmium is a Core Data framework for Swift that enforces best practices and raises exceptions for common Core Data pitfalls exactly where you make the

Jason Fieldman 123 Oct 18, 2022
100% Swift Simple Boilerplate Free Core Data Stack. NSPersistentContainer

DATAStack helps you to alleviate the Core Data boilerplate. Now you can go to your AppDelegate remove all the Core Data related code and replace it wi

Nes 216 Jan 3, 2023
An NSPredicate DSL for iOS, OSX, tvOS, & watchOS. Inspired by SnapKit and lovingly written in Swift.

PrediKit A Swift NSPredicate DSL for iOS & OS X inspired by SnapKit, lovingly written in Swift, and created by that weird dude at KrakenDev. If you're

Hector Matos 542 Sep 24, 2022
🎯 PredicateKit allows Swift developers to write expressive and type-safe predicates for CoreData using key-paths, comparisons and logical operators, literal values, and functions.

?? PredicateKit PredicateKit is an alternative to NSPredicate allowing you to write expressive and type-safe predicates for CoreData using key-paths,

Faiçal Tchirou 352 Jan 3, 2023
This project server as a demo for anyone who wishes to learn Core Data in Swift.

CoreDataDemo This project server as a demo for anyone who wishes to learn Core Data in Swift. The purpose of this project is to help someone new to Co

null 1 May 3, 2022
Core functionality for Swift projects

Swift library with our shared code How to install .package(url: "https://github.com/ydataai/swift-core.git", from: "master"), About ??‍♂️ With ❤️ from

YData 4 Dec 14, 2022
Generates Swift NSManagedObject subclasses

MotoSwift. Managed Objects to Swift. Generates Swift NSManagedObject subclasses. Benefits Why is it better than Xcode generation? Xcode generates prop

null 14 Apr 29, 2022
Swift Package for deduplicating entity protocol.

DeDuplicatingEntity DeDuplicatingEntity is a protocol you can add to your Core Data model types to give them the functionality to deduplicate their in

Vic Hudson 1 Jun 19, 2022
Arctanyn 0 Dec 24, 2022
SwiftFM is a Swift framework for the FileMaker Data API

SwiftFM SwiftFM is a Swift framework for the FileMaker Data API (Swift 5.5, iOS 15 required). It utilizes modern Swift features like async/await and i

Brian Hamm 48 Nov 3, 2022