Skip to content

Commit 7e4c1bb

Browse files
pontomedoncramsannbransbyReedyuk
authored
Adding JVM support for Firebase Storage (#704)
* Adding storage to the JVM target * removed duplicate dependency * avoid 0 CONTENT_LENGTH - the header goes missing on desktop, causing Firebase to throw a 411 * remove a useless test case --------- Co-authored-by: cramsan <contact@cramsan.com> Co-authored-by: Nicholas Bransby-Williams <nbransby@gmail.com> Co-authored-by: Andrew Reed <andrew_reed@hotmail.com>
1 parent b484a6a commit 7e4c1bb

File tree

3 files changed

+8
-105
lines changed

3 files changed

+8
-105
lines changed

firebase-storage/build.gradle.kts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ kotlin {
127127
getByName("commonMain") {
128128
dependencies {
129129
api(project(":firebase-app"))
130-
implementation(project(":firebase-common"))
130+
api(project(":firebase-common"))
131131
}
132132
}
133133

@@ -142,6 +142,10 @@ kotlin {
142142
api(libs.google.firebase.storage)
143143
}
144144
}
145+
146+
getByName("jvmMain") {
147+
kotlin.srcDir("src/androidMain/kotlin")
148+
}
145149
}
146150
}
147151

firebase-storage/src/androidMain/kotlin/dev/gitlive/firebase/storage/storage.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,23 +85,23 @@ public actual class StorageReference(internal val android: com.google.firebase.s
8585
if (metadata != null) {
8686
android.putFile(file.uri, metadata.toStorageMetadata()).await().run {}
8787
} else {
88-
android.putFile(file.uri).await().run {}
88+
android.putFile(file.uri, FirebaseStorageMetadata().toStorageMetadata()).await().run {}
8989
}
9090
}
9191

9292
public actual suspend fun putData(data: Data, metadata: FirebaseStorageMetadata?) {
9393
if (metadata != null) {
9494
android.putBytes(data.data, metadata.toStorageMetadata()).await().run {}
9595
} else {
96-
android.putBytes(data.data).await().run {}
96+
android.putBytes(data.data, FirebaseStorageMetadata().toStorageMetadata()).await().run {}
9797
}
9898
}
9999

100100
public actual fun putFileResumable(file: File, metadata: FirebaseStorageMetadata?): ProgressFlow {
101101
val android = if (metadata != null) {
102102
android.putFile(file.uri, metadata.toStorageMetadata())
103103
} else {
104-
android.putFile(file.uri)
104+
android.putFile(file.uri, FirebaseStorageMetadata().toStorageMetadata())
105105
}
106106

107107
val flow = callbackFlow {

firebase-storage/src/jvmMain/kotlin/dev/gitlive/firebase/storage/storage.jvm.kt

Lines changed: 0 additions & 101 deletions
This file was deleted.

0 commit comments

Comments
 (0)