GitLiveApp / firebase-kotlin-sdk

A Kotlin-first SDK for Firebase
https://gitliveapp.github.io/firebase-kotlin-sdk/
Apache License 2.0
1.16k stars 156 forks source link

Add FirebaseStorage for Android and iOS #193

Closed tiagonuneslx closed 1 year ago

tiagonuneslx commented 3 years ago
Library Class Platforms
storage FirebaseStorage Android, iOS
mjmarathon commented 3 years ago

I need this module for the app I'm currently building so I'm taking a crack at it. Does anyone have any guidance on how to handle the two platform apis being different? E.g. Android's StorageReference.get/putStream() vs ios' nothing.

nbransby commented 3 years ago

Hi @mjmarathon can you send links to the API docs for the methods you mentioned? Generally, the best way to handle these difference is to find the kotlin way to do the same kind of thing use that instead - for example, the 3 platforms all have different ways to serialise objects so we use kotlin serialization and convert to the platform specific formats under the hood

mjmarathon commented 3 years ago

Hey there @nbransby! Thanks for the quick follow up.

Docs for the aforementioned methods here: https://firebase.google.com/docs/reference/android/com/google/firebase/storage/StorageReference#getStream(com.google.firebase.storage.StreamDownloadTask.StreamProcessor) https://firebase.google.com/docs/reference/android/com/google/firebase/storage/StorageReference#putStream(java.io.InputStream,%20com.google.firebase.storage.StorageMetadata)

If the ios platform sdk doesn't support/use streams I'm unsure about how to keep the streaming methods exposed.

tiagonuneslx commented 3 years ago

I need this module for the app I'm currently building so I'm taking a crack at it. Does anyone have any guidance on how to handle the two platform apis being different? E.g. Android's StorageReference.get/putStream() vs ios' nothing.

I can think of 3 ways to solve that issue:

I think the 3rd option is the best, at least inside the library. Not everything should be shared. And if you want, you can create an extension function in your final shared code, that calls putFile on iOS and putStream on Android.

michaelprichardson commented 1 year ago

Was added in https://github.com/GitLiveApp/firebase-kotlin-sdk/pull/393