FirebaseStorage
class FirebaseStorage
FirebaseStorage is a service that supports uploading and downloading large objects to Google Cloud Storage. Pass a custom instance of FirebaseApp to getInstance which will initialize it with a storage location (bucket) specified via setStorageBucket.
Otherwise, if you call getReference without a FirebaseApp, the FirebaseStorage instance will initialize with the default FirebaseApp obtainable from getInstance. The storage location in this case will come the JSON configuration file downloaded from the web.
Summary
Public functions |
|
|---|---|
FirebaseApp |
getApp()The |
java-static FirebaseStorage |
Returns the |
java-static FirebaseStorage |
getInstance(app: FirebaseApp)Returns the |
java-static FirebaseStorage |
getInstance(url: String)Returns the |
java-static FirebaseStorage |
getInstance(app: FirebaseApp, url: String)Returns the |
Long |
Returns the maximum time to retry sending a chunk if a failure occurs |
Long |
Returns the maximum time to retry a download if a failure occurs. |
Long |
Returns the maximum time to retry operations other than upload and download if a failure occurs. |
Long |
Returns the maximum time to retry an upload if a failure occurs. |
StorageReference |
Creates a new |
StorageReference |
getReference(location: String)Creates a new |
StorageReference |
getReferenceFromUrl(fullUrl: String)Creates a |
Unit |
setMaxChunkUploadRetry(maxChunkRetryMillis: Long)Sets the maximum time to retry sending a chunk if a failure occurs |
Unit |
setMaxDownloadRetryTimeMillis(maxTransferRetryMillis: Long)Sets the maximum time to retry a download if a failure occurs. |
Unit |
setMaxOperationRetryTimeMillis(maxTransferRetryMillis: Long)Sets the maximum time to retry operations other than upload and download if a failure occurs. |
Unit |
setMaxUploadRetryTimeMillis(maxTransferRetryMillis: Long)Sets the maximum time to retry an upload if a failure occurs. |
Unit |
useEmulator(host: String, port: Int)Modifies this FirebaseStorage instance to communicate with the Storage emulator. |
Public functions
getInstance
java-static fun getInstance(): FirebaseStorage
Returns the FirebaseStorage, initialized with the default FirebaseApp.
| Returns | |
|---|---|
FirebaseStorage |
a |
getInstance
java-static fun getInstance(app: FirebaseApp): FirebaseStorage
Returns the FirebaseStorage, initialized with a custom FirebaseApp
| Parameters | |
|---|---|
app: FirebaseApp |
The custom |
| Returns | |
|---|---|
FirebaseStorage |
a |
getInstance
java-static fun getInstance(url: String): FirebaseStorage
Returns the FirebaseStorage, initialized with the default FirebaseApp and a custom Storage Bucket.
| Parameters | |
|---|---|
url: String |
The gs:// url to your Firebase Storage Bucket. |
| Returns | |
|---|---|
FirebaseStorage |
a |
getInstance
java-static fun getInstance(app: FirebaseApp, url: String): FirebaseStorage
Returns the FirebaseStorage, initialized with a custom FirebaseApp and a custom Storage Bucket.
| Parameters | |
|---|---|
app: FirebaseApp |
The custom |
url: String |
The gs:// url to your Firebase Storage Bucket. |
| Returns | |
|---|---|
FirebaseStorage |
a |
getMaxChunkUploadRetry
fun getMaxChunkUploadRetry(): Long
Returns the maximum time to retry sending a chunk if a failure occurs
| Returns | |
|---|---|
Long |
maximum time in milliseconds. Defaults to 1 minute. |
getMaxDownloadRetryTimeMillis
fun getMaxDownloadRetryTimeMillis(): Long
Returns the maximum time to retry a download if a failure occurs.
| Returns | |
|---|---|
Long |
maximum time in milliseconds. Defaults to 10 minutes (600,000 milliseconds). |
getMaxOperationRetryTimeMillis
fun getMaxOperationRetryTimeMillis(): Long
Returns the maximum time to retry operations other than upload and download if a failure occurs.
| Returns | |
|---|---|
Long |
the maximum time in milliseconds. Defaults to 2 minutes (120,000 milliseconds). |
getMaxUploadRetryTimeMillis
fun getMaxUploadRetryTimeMillis(): Long
Returns the maximum time to retry an upload if a failure occurs.
| Returns | |
|---|---|
Long |
the maximum time in milliseconds. Defaults to 10 minutes (600,000 milliseconds). |
getReference
fun getReference(): StorageReference
Creates a new StorageReference initialized at the root Firebase Storage location.
| Returns | |
|---|---|
StorageReference |
An instance of |
getReference
fun getReference(location: String): StorageReference
Creates a new StorageReference initialized with a child Firebase Storage location.
| Parameters | |
|---|---|
location: String |
A relative path from the root to initialize the reference with, for instance "path/to/object" |
| Returns | |
|---|---|
StorageReference |
An instance of |
getReferenceFromUrl
fun getReferenceFromUrl(fullUrl: String): StorageReference
Creates a StorageReference given a gs:// or https:// URL pointing to a Firebase Storage location.
| Parameters | |
|---|---|
fullUrl: String |
A gs:// or http[s]:// URL used to initialize the reference. For example, you can pass in a download URL retrieved from |
setMaxChunkUploadRetry
fun setMaxChunkUploadRetry(maxChunkRetryMillis: Long): Unit
Sets the maximum time to retry sending a chunk if a failure occurs
| Parameters | |
|---|---|
maxChunkRetryMillis: Long |
the maximum time in milliseconds. Defaults to 1 minute (60,000 milliseconds). |
setMaxDownloadRetryTimeMillis
fun setMaxDownloadRetryTimeMillis(maxTransferRetryMillis: Long): Unit
Sets the maximum time to retry a download if a failure occurs.
| Parameters | |
|---|---|
maxTransferRetryMillis: Long |
the maximum time in milliseconds. Defaults to 10 minutes (600,000 milliseconds). |
setMaxOperationRetryTimeMillis
fun setMaxOperationRetryTimeMillis(maxTransferRetryMillis: Long): Unit
Sets the maximum time to retry operations other than upload and download if a failure occurs.
| Parameters | |
|---|---|
maxTransferRetryMillis: Long |
the maximum time in milliseconds. Defaults to 2 minutes (120,000 milliseconds). |
setMaxUploadRetryTimeMillis
fun setMaxUploadRetryTimeMillis(maxTransferRetryMillis: Long): Unit
Sets the maximum time to retry an upload if a failure occurs.
| Parameters | |
|---|---|
maxTransferRetryMillis: Long |
the maximum time in milliseconds. Defaults to 10 minutes (600,000 milliseconds). |
useEmulator
fun useEmulator(host: String, port: Int): Unit
Modifies this FirebaseStorage instance to communicate with the Storage emulator.
Note: Call this method before using the instance to do any storage operations.