Storage Kotlin Extensions

Getting Started

To use the Cloud Storage Android SDK with Kotlin Extensions, add the following to your app's build.gradle file:

// See for the latest versions
// This library transitively includes the firebase-storage library
implementation '$VERSION'


Get an instance of FirebaseStorage


val storage = FirebaseStorage.getInstance()
val anotherStorage = FirebaseStorage.getInstance(FirebaseApp.getInstance("myApp"))

Kotlin + KTX

val storage =
val anotherStorage ="myApp"))

Get the FirebaseStorage for a custom storage bucket url


val storage = FirebaseStorage.getInstance("gs://my-custom-bucket")
val anotherStorage = FirebaseStorage.getInstance(FirebaseApp.getInstance("myApp"), "gs://my-custom-bucket")

Kotlin + KTX

val storage ="gs://my-custom-bucket")
val anotherStorage ="myApp"), "gs://my-custom-bucket")

Create file metadata


val metadata = StorageMetadata.Builder()
        .setCustomMetadata("location", "Maputo, MOZ")

Kotlin + KTX

val metadata = storageMetadata {
    contentType = "image/jpg"
    contentDisposition = "attachment"
    setCustomMetadata("location", "Maputo, MOZ")