-
Notifications
You must be signed in to change notification settings - Fork 147
/
storage.kt
68 lines (48 loc) · 1.9 KB
/
storage.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package dev.gitlive.firebase.storage
import dev.gitlive.firebase.Firebase
import dev.gitlive.firebase.FirebaseApp
import dev.gitlive.firebase.FirebaseException
import kotlinx.coroutines.flow.Flow
/** Returns the [FirebaseStorage] instance of the default [FirebaseApp]. */
expect val Firebase.storage: FirebaseStorage
/** Returns the [FirebaseStorage] instance of a given [FirebaseApp]. */
expect fun Firebase.storage(app: FirebaseApp): FirebaseStorage
expect class FirebaseStorage {
val maxOperationRetryTimeMillis: Long
val maxUploadRetryTimeMillis: Long
fun setMaxOperationRetryTimeMillis(maxOperationRetryTimeMillis: Long)
fun setMaxUploadRetryTimeMillis(maxUploadRetryTimeMillis: Long)
fun useEmulator(host: String, port: Int)
val reference: StorageReference
fun reference(location: String): StorageReference
}
expect class StorageReference {
val name: String
val path: String
val bucket: String
val parent: StorageReference?
val root: StorageReference
val storage: FirebaseStorage
fun child(path: String): StorageReference
suspend fun delete()
suspend fun getDownloadUrl(): String
suspend fun listAll(): ListResult
suspend fun putFile(file: File)
fun putFileResumable(file: File): ProgressFlow
}
expect class ListResult {
val prefixes: List<StorageReference>
val items: List<StorageReference>
val pageToken: String?
}
expect class File
sealed class Progress(val bytesTransferred: Number, val totalByteCount: Number) {
class Running internal constructor(bytesTransferred: Number, totalByteCount: Number): Progress(bytesTransferred, totalByteCount)
class Paused internal constructor(bytesTransferred: Number, totalByteCount: Number): Progress(bytesTransferred, totalByteCount)
}
interface ProgressFlow : Flow<Progress> {
fun pause()
fun resume()
fun cancel()
}
expect class FirebaseStorageException : FirebaseException