StorageReference

class StorageReference : NSObject

FIRStorageReference represents a reference to a Google Cloud Storage object. Developers can upload and download objects, as well as get/set object metadata, and delete an object at the path.

  • The FIRStorage service object which created this reference.

    Declaration

    Swift

    var storage: Storage { get }
  • The name of the Google Cloud Storage bucket associated with this reference, in gs://bucket/path/to/object.txt, the bucket would be: ‘bucket’

    Declaration

    Swift

    var bucket: String { get }
  • The full path to this object, not including the Google Cloud Storage bucket. In gs://bucket/path/to/object.txt, the full path would be: ‘path/to/object.txt’

    Declaration

    Swift

    var fullPath: String { get }
  • The short name of the object associated with this reference, in gs://bucket/path/to/object.txt, the name of the object would be: ‘object.txt’

    Declaration

    Swift

    var name: String { get }
  • Creates a new FIRStorageReference pointing to the root object.

    Declaration

    Swift

    func root() -> StorageReference

    Return Value

    A new FIRStorageReference pointing to the root object.

  • Creates a new FIRStorageReference pointing to the parent of the current reference or nil if this instance references the root location. For example: path = foo/bar/baz parent = foo/bar path = foo parent = (root) path = (root) parent = nil

    Declaration

    Swift

    func parent() -> StorageReference?

    Return Value

    A new FIRStorageReference pointing to the parent of the current reference.

  • Creates a new FIRStorageReference pointing to a child object of the current reference. path = foo child = bar newPath = foo/bar path = foo/bar child = baz newPath = foo/bar/baz All leading and trailing slashes will be removed, and consecutive slashes will be compressed to single slashes. For example: child = /foo/bar newPath = foo/bar child = foo/bar/ newPath = foo/bar child = foo///bar newPath = foo/bar

    Declaration

    Swift

    func child(_ path: String) -> StorageReference

    Parameters

    path

    Path to append to the current path.

    Return Value

    A new FIRStorageReference pointing to a child location of the current reference.

  • Asynchronously uploads data to the currently specified FIRStorageReference, without additional metadata. This is not recommended for large files, and one should instead upload a file from disk.

    Declaration

    Swift

    func putData(_ uploadData: Data) -> StorageUploadTask

    Parameters

    uploadData

    The NSData to upload.

    Return Value

    An instance of FIRStorageUploadTask, which can be used to monitor or manage the upload.

  • Asynchronously uploads data to the currently specified FIRStorageReference. This is not recommended for large files, and one should instead upload a file from disk.

    Declaration

    Swift

    func putData(_ uploadData: Data, metadata: StorageMetadata?) -> StorageUploadTask

    Parameters

    uploadData

    The NSData to upload.

    metadata

    FIRStorageMetadata containing additional information (MIME type, etc.) about the object being uploaded.

    Return Value

    An instance of FIRStorageUploadTask, which can be used to monitor or manage the upload.

  • Asynchronously uploads data to the currently specified FIRStorageReference. This is not recommended for large files, and one should instead upload a file from disk.

    Declaration

    Swift

    func putData(_ uploadData: Data, metadata: StorageMetadata?, completion: ((StorageMetadata?, Error?) -> Void)? = nil) -> StorageUploadTask

    Parameters

    uploadData

    The NSData to upload.

    metadata

    FIRStorageMetadata containing additional information (MIME type, etc.) about the object being uploaded.

    completion

    A completion block that either returns the object metadata on success, or an error on failure.

    Return Value

    An instance of FIRStorageUploadTask, which can be used to monitor or manage the upload.

  • Asynchronously uploads a file to the currently specified FIRStorageReference, without additional metadata.

    Declaration

    Swift

    func putFile(from fileURL: URL) -> StorageUploadTask

    Parameters

    fileURL

    A URL representing the system file path of the object to be uploaded.

    Return Value

    An instance of FIRStorageUploadTask, which can be used to monitor or manage the upload.

  • Asynchronously uploads a file to the currently specified FIRStorageReference.

    Declaration

    Swift

    func putFile(from fileURL: URL, metadata: StorageMetadata?) -> StorageUploadTask

    Parameters

    fileURL

    A URL representing the system file path of the object to be uploaded.

    metadata

    FIRStorageMetadata containing additional information (MIME type, etc.) about the object being uploaded.

    Return Value

    An instance of FIRStorageUploadTask, which can be used to monitor or manage the upload.

  • Asynchronously uploads a file to the currently specified FIRStorageReference.

    Declaration

    Swift