FirebaseStorage Framework Reference

Storage

@objc(FIRStorage)
open class Storage : 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 of Storage are not thread-safe, but can be accessed from any thread.

If you call Storage.storage(), the instance will initialize with the default FirebaseApp, FirebaseApp.app(), and the storage location will come from the provided GoogleService-Info.plist.

If you provide a custom instance of FirebaseApp, the storage location will be specified via the FirebaseOptions.storageBucket property.

  • The default Storage instance.

    Declaration

    Swift

    @objc(storage)
    open class func storage() -> Storage

    Return Value

    An instance of Storage, configured with the default FirebaseApp.

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

    Any StorageReferences generated from this instance of Storage will reference files and directories within the specified bucket.

    Declaration

    Swift

    @objc(storageWithURL:)
    open class func storage(url: String) -> Storage

    Parameters

    url

    The gs:// URL to your Firebase Storage bucket.

    Return Value

    A Storage instance, configured with the custom storage bucket.

  • Creates an instance of Storage, configured with a custom FirebaseApp. StorageReferences generated from a resulting instance will reference files in the Firebase project associated with custom FirebaseApp.

    Declaration

    Swift

    @objc(storageForApp:)
    open class func storage(app: FirebaseApp) -> Storage

    Parameters

    app

    The custom FirebaseApp used for initialization.

    Return Value

    A Storage instance, configured with the custom FirebaseApp.

  • Creates an instance of Storage, configured with a custom FirebaseApp and a custom storage bucket URL.

    Declaration

    Swift

    @objc(storageForApp:URL:)
    open class func storage(app: FirebaseApp, url: String) -> Storage

    Parameters

    app

    The custom FirebaseApp used for initialization.

    url

    The gs:// url to your Firebase Storage bucket.

    Return Value

    The Storage instance, configured with the custom FirebaseApp and storage bucket URL.

  • app

    The FirebaseApp associated with this Storage instance.

    Declaration

    Swift

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

    Declaration

    Swift

    @objc
    public var maxUploadRetryTime: TimeInterval { get set }
  • The maximum time in seconds to retry a download if a failure occurs. Defaults to 10 minutes (600 seconds).

    Declaration

    Swift

    @objc
    public var maxDownloadRetryTime: TimeInterval { get set }
  • The maximum time in seconds to retry operations other than upload and download if a failure occurs. Defaults to 2 minutes (120 seconds).

    Declaration

    Swift

    @objc
    public var maxOperationRetryTime: TimeInterval { get set }
  • Specify the maximum upload chunk size. Values less than 256K (262144) will be rounded up to 256K. Values above 256K will be rounded down to the nearest 256K multiple. The default is no maximum.

    Declaration

    Swift

    @objc
    public var uploadChunkSizeBytes: Int64
  • A DispatchQueue that all developer callbacks are fired on. Defaults to the main queue.

    Declaration

    Swift

    @objc
    public var callbackQueue: DispatchQueue { get set }
  • Creates a StorageReference initialized at the root Firebase Storage location.

    Declaration

    Swift

    @objc
    open func reference() -> StorageReference

    Return Value

    An instance of StorageReference referencing the root of the storage bucket.

  • Creates a StorageReference given a gs://, http://, or https:// URL pointing to a Firebase Storage location.

    For example, you can pass in an https:// download URL retrieved from StorageReference.downloadURL(completion:) or the gs:// URL from StorageReference.description.

    Throws

    Throws a fatal error if url is not associated with the FirebaseApp used to initialize this Storage instance.

    Declaration

    Swift

    @objc
    open func reference(forURL url: 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 a gs://, http://, or https:// URL pointing to a Firebase Storage location.

    For example, you can pass in an https:// download URL retrieved from StorageReference.downloadURL(completion:) or the gs:// URL from StorageReference.description.

    Throws

    Throws an Error if url is not associated with the FirebaseApp used to initialize this Storage instance.

    Declaration

    Swift

    open func reference(for url: 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 a StorageReference initialized at a location specified by the path parameter.

    Declaration

    Swift

    @objc(referenceWithPath:)
    open func reference(withPath path: String) -> StorageReference

    Parameters

    path

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

    Return Value

    An instance of StorageReference 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 of Storage.

    Declaration

    Swift

    @objc
    open func useEmulator(withHost host: String, port: Int)

    Parameters

    host

    A string specifying the host.

    port

    The port specified as an Int.

  • Undocumented

    Declaration

    Swift

    override open func copy() -> Any
  • Undocumented

    Declaration

    Swift

    override open func isEqual(_ object: Any?) -> Bool
  • Undocumented

    Declaration

    Swift

    override public var hash: Int { get }