FirebaseStorage Framework Reference

Storage

@available(iOS13,tvOS13,macOS10.15,watchOS7,*)@objc(FIRStorage)openclassStorage:NSObject

Firebase Storage is a service that supports uploading and downloading binary objects,such as images, videos, and other files to Google Cloud Storage. Instances ofStorageare not thread-safe, but can be accessed from any thread.

If you callStorage.storage(), the instance will initialize with the defaultFirebaseApp,FirebaseApp.app(), and the storage location will come from the providedGoogleService-Info.plist.

If you provide a custom instance ofFirebaseApp,the storage location will be specified via theFirebaseOptions.storageBucket property.

  • The defaultStorage instance.

    Declaration

    Swift

    @objc(storage)openclassfuncstorage()->Storage

    Return Value

    An instance ofStorage, configured with the defaultFirebaseApp.

  • A method used to createStorage instances initialized with a custom storage bucket URL.

    AnyStorageReferences generated from this instance ofStorage will reference filesand directories within the specified bucket.

    Declaration

    Swift

    @objc(storageWithURL:)openclassfuncstorage(url:String)->Storage

    Parameters

    url

    Thegs:// URL to your Firebase Storage bucket.

    Return Value

    AStorage instance, configured with the custom storage bucket.

  • Creates an instance ofStorage, configured with a customFirebaseApp.StorageReferencesgenerated from a resulting instance will reference files in the Firebase projectassociated with customFirebaseApp.

    Declaration

    Swift

    @objc(storageForApp:)openclassfuncstorage(app:FirebaseApp)->Storage

    Parameters

    app

    The customFirebaseApp used for initialization.

    Return Value

    AStorage instance, configured with the customFirebaseApp.

  • Creates an instance ofStorage, configured with a customFirebaseApp and a custom storagebucket URL.

    Declaration

    Swift

    @objc(storageForApp:URL:)openclassfuncstorage(app:FirebaseApp,url:String)->Storage

    Parameters

    app

    The customFirebaseApp used for initialization.

    url

    Thegs:// url to your Firebase Storage bucket.

    Return Value

    TheStorage instance, configured with the customFirebaseApp and storage bucketURL.

  • TheFirebaseApp associated with this Storage instance.

    Declaration

    Swift

    @objcpublicletapp:FirebaseApp
  • The maximum time in seconds to retry an upload if a failure occurs.Defaults to 10 minutes (600 seconds).

    Declaration

    Swift

    @objcpublicvarmaxUploadRetryTime:TimeInterval{getset}
  • The maximum time in seconds to retry a download if a failure occurs.Defaults to 10 minutes (600 seconds).

    Declaration

    Swift

    @objcpublicvarmaxDownloadRetryTime:TimeInterval{getset}
  • The maximum time in seconds to retry operations other than upload and download if a failureoccurs.Defaults to 2 minutes (120 seconds).

    Declaration

    Swift

    @objcpublicvarmaxOperationRetryTime:TimeInterval{getset}
  • Specify the maximum upload chunk size. Values less than 256K (262144) will be rounded up to256K. Valuesabove 256K will be rounded down to the nearest 256K multiple. The default is no maximum.

    Declaration

    Swift

    @objcpublicvaruploadChunkSizeBytes:Int64
  • ADispatchQueue that all developer callbacks are fired on. Defaults to the main queue.

    Declaration

    Swift

    @objcpublicvarcallbackQueue:DispatchQueue
  • Creates aStorageReference initialized at the root Firebase Storage location.

    Declaration

    Swift

    @available(iOS13,tvOS13,macOS10.15,watchOS7,*)@objcopenfuncreference()->StorageReference

    Return Value

    An instance ofStorageReference referencing the root of the storage bucket.

  • Creates a StorageReference given ags://,http://, orhttps:// URL pointing to aFirebase Storage location.

    For example, you can pass in anhttps:// download URL retrieved fromStorageReference.downloadURL(completion:) or thegs:// URL fromStorageReference.description.

    Throws

    Throws a fatal error ifurl is not associated with theFirebaseApp used toinitialize this Storage instance.

    Declaration

    Swift

    @available(iOS13,tvOS13,macOS10.15,watchOS7,*)@objcopenfuncreference(forURLurl:String)->StorageReference

    Parameters

    url

    A gs:// or https:// URL to initialize the reference with.

    Return Value

    An instance of StorageReference at the given child path.

  • Creates a StorageReference given ags://,http://, orhttps:// URL pointing to aFirebase Storage location.

    For example, you can pass in anhttps:// download URL retrieved fromStorageReference.downloadURL(completion:) or thegs:// URL fromStorageReference.description.

    Throws

    Throws an Error ifurl is not associated with theFirebaseApp used to initializethis Storage instance.

    Declaration

    Swift

    openfuncreference(forurl:URL)throws->StorageReference

    Parameters

    url

    A gs:// or https:// URL to initialize the reference with.

    Return Value

    An instance of StorageReference at the given child path.

  • Creates aStorageReference initialized at a location specified by thepath parameter.

    Declaration

    Swift

    @objc(referenceWithPath:)openfuncreference(withPathpath:String)->StorageReference

    Parameters

    path

    A relative path from the root of the storage bucket,for instance @“path/to/object”.

    Return Value

    An instance ofStorageReference pointing to the given path.

  • Configures the Storage SDK to use an emulated backend instead of the default remote backend.

    This method should be called before invoking any other methods on a new instance ofStorage.

    Declaration

    Swift

    @objcopenfuncuseEmulator(withHosthost:String,port:Int)

    Parameters

    host

    A string specifying the host.

    port

    The port specified as anInt.

  • Undocumented

    Declaration

    Swift

    overrideopenfunccopy()->Any
  • Undocumented

    Declaration

    Swift

    overrideopenfuncisEqual(_object:Any?)->Bool
  • Undocumented

    Declaration

    Swift

    overridepublicvarhash:Int{get}

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2024-08-19 UTC.