FirebaseStorage
public 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 methods |
|
|---|---|
@NonNull FirebaseApp |
getApp()The |
static @NonNull FirebaseStorage |
Returns the |
static @NonNull FirebaseStorage |
getInstance(@NonNull FirebaseApp app)Returns the |
static @NonNull FirebaseStorage |
getInstance(@NonNull String url)Returns the |
static @NonNull FirebaseStorage |
getInstance(@NonNull FirebaseApp app, @NonNull String url)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. |
@NonNull StorageReference |
Creates a new |
@NonNull StorageReference |
getReference(@NonNull String location)Creates a new |
@NonNull StorageReference |
getReferenceFromUrl(@NonNull String fullUrl)Creates a |
void |
setMaxChunkUploadRetry(long maxChunkRetryMillis)Sets the maximum time to retry sending a chunk if a failure occurs |
void |
setMaxDownloadRetryTimeMillis(long maxTransferRetryMillis)Sets the maximum time to retry a download if a failure occurs. |
void |
setMaxOperationRetryTimeMillis(long maxTransferRetryMillis)Sets the maximum time to retry operations other than upload and download if a failure occurs. |
void |
setMaxUploadRetryTimeMillis(long maxTransferRetryMillis)Sets the maximum time to retry an upload if a failure occurs. |
void |
useEmulator(@NonNull String host, int port)Modifies this FirebaseStorage instance to communicate with the Storage emulator. |
Public methods
getApp
public @NonNull FirebaseApp getApp()
The FirebaseApp associated with this FirebaseStorage instance.
getInstance
public static @NonNull FirebaseStorage getInstance()
Returns the FirebaseStorage, initialized with the default FirebaseApp.
| Returns | |
|---|---|
@NonNull FirebaseStorage |
a |
getInstance
public static @NonNull FirebaseStorage getInstance(@NonNull FirebaseApp app)
Returns the FirebaseStorage, initialized with a custom FirebaseApp
| Parameters | |
|---|---|
@NonNull FirebaseApp app |
The custom |
| Returns | |
|---|---|
@NonNull FirebaseStorage |
a |
getInstance
public static @NonNull FirebaseStorage getInstance(@NonNull String url)
Returns the FirebaseStorage, initialized with the default FirebaseApp and a custom Storage Bucket.
| Returns | |
|---|---|
@NonNull FirebaseStorage |
a |
getInstance
public static @NonNull FirebaseStorage getInstance(@NonNull FirebaseApp app, @NonNull String url)
Returns the FirebaseStorage, initialized with a custom FirebaseApp and a custom Storage Bucket.
| Parameters | |
|---|---|
@NonNull FirebaseApp app |
The custom |
@NonNull String url |
The gs:// url to your Firebase Storage Bucket. |
| Returns | |
|---|---|
@NonNull FirebaseStorage |
a |
getMaxChunkUploadRetry
public long getMaxChunkUploadRetry()
Returns the maximum time to retry sending a chunk if a failure occurs
| Returns | |
|---|---|
long |
maximum time in milliseconds. Defaults to 1 minute. |
getMaxDownloadRetryTimeMillis
public long getMaxDownloadRetryTimeMillis()
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
public long getMaxOperationRetryTimeMillis()
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
public long getMaxUploadRetryTimeMillis()
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
public @NonNull StorageReference getReference()
Creates a new StorageReference initialized at the root Firebase Storage location.
| Returns | |
|---|---|
@NonNull StorageReference |
An instance of |
getReference
public @NonNull StorageReference getReference(@NonNull String location)
Creates a new StorageReference initialized with a child Firebase Storage location.
| Parameters | |
|---|---|
@NonNull String location |
A relative path from the root to initialize the reference with, for instance "path/to/object" |
| Returns | |
|---|---|
@NonNull StorageReference |
An instance of |
getReferenceFromUrl
public @NonNull StorageReference getReferenceFromUrl(@NonNull String fullUrl)
Creates a StorageReference given a gs:// or https:// URL pointing to a Firebase Storage location.
| Parameters | |
|---|---|
@NonNull String fullUrl |
A gs:// or http[s]:// URL used to initialize the reference. For example, you can pass in a download URL retrieved from |
setMaxChunkUploadRetry
public void setMaxChunkUploadRetry(long maxChunkRetryMillis)
Sets the maximum time to retry sending a chunk if a failure occurs
| Parameters | |
|---|---|
long maxChunkRetryMillis |
the maximum time in milliseconds. Defaults to 1 minute (60,000 milliseconds). |
setMaxDownloadRetryTimeMillis
public void setMaxDownloadRetryTimeMillis(long maxTransferRetryMillis)
Sets the maximum time to retry a download if a failure occurs.
| Parameters | |
|---|---|
long maxTransferRetryMillis |
the maximum time in milliseconds. Defaults to 10 minutes (600,000 milliseconds). |
setMaxOperationRetryTimeMillis
public void setMaxOperationRetryTimeMillis(long maxTransferRetryMillis)
Sets the maximum time to retry operations other than upload and download if a failure occurs.
| Parameters | |
|---|---|
long maxTransferRetryMillis |
the maximum time in milliseconds. Defaults to 2 minutes (120,000 milliseconds). |
setMaxUploadRetryTimeMillis
public void setMaxUploadRetryTimeMillis(long maxTransferRetryMillis)
Sets the maximum time to retry an upload if a failure occurs.
| Parameters | |
|---|---|
long maxTransferRetryMillis |
the maximum time in milliseconds. Defaults to 10 minutes (600,000 milliseconds). |
useEmulator
public void useEmulator(@NonNull String host, int port)
Modifies this FirebaseStorage instance to communicate with the Storage emulator.
Note: Call this method before using the instance to do any storage operations.