Naar console

Firebase.Storage.StorageReference

Represents a reference to a Google Cloud Storage object.

Summary

Represents a reference to a Google Cloud Storage object. Developers can upload and download objects, get/set object metadata, and delete an object at a specified path. (see Google Cloud Storage)

Properties

Bucket
string
Return the Google Cloud Storage bucket that holds this object.
Name
string
Returns the short name of this object.
Parent
Returns a new instance of StorageReference pointing to the parent location or null if this instance references the root location.
Path
string
Returns the full path to this object, not including the Google Cloud Storage bucket.
Root
Returns a new instance of StorageReference pointing to the root location.
Storage
Returns the FirebaseStorage service which created this reference.

Public functions

Child(string pathString)
Returns a new instance of StorageReference pointing to a child location of the current reference.
DeleteAsync()
Deletes the object at this StorageReference
Equals(object other)
override bool
Compares two storage reference URIs.
GetBytesAsync(long maxDownloadSizeBytes)
Task< byte[]>
Downloads the object from this StorageReference A byte array will be allocated large enough to hold the entire file in memory.
GetBytesAsync(long maxDownloadSizeBytes, IProgress< DownloadState > progressHandler, CancellationToken cancelToken)
Task< byte[]>
Downloads the object from this StorageReference A byte array will be allocated large enough to hold the entire file in memory.
GetDownloadUrlAsync()
Task< Uri >
Retrieves a long lived download URL with a revokable token.
GetFileAsync(string destinationFilePath, IProgress< DownloadState > progressHandler, CancellationToken cancelToken)
Downloads the object at this StorageReference to a specified system filepath.
GetHashCode()
override int
Create a hash of the URI string used by this reference.
GetMetadataAsync()
Retrieves metadata associated with an object at this StorageReference
GetStreamAsync()
Task< Stream >
Downloads the object at this StorageReference via a Stream The resulting InputStream should be not be accessed on the main thread because calling into it may block the calling thread.
GetStreamAsync(Action< Stream > streamProcessor, IProgress< DownloadState > progressHandler, CancellationToken cancelToken)
Downloads the object at this StorageReference via a Stream
PutBytesAsync(byte[] bytes, MetadataChange customMetadata, IProgress< UploadState > progressHandler, CancellationToken cancelToken, Uri previousSessionUri)
Uploads byte data to this StorageReference This is not recommended for large files.
PutFileAsync(string filePath, MetadataChange customMetadata, IProgress< UploadState > progressHandler, CancellationToken cancelToken, Uri previousSessionUri)
Uploads from a content URI to this StorageReference
PutStreamAsync(Stream stream, MetadataChange customMetadata, IProgress< UploadState > progressHandler, CancellationToken cancelToken, Uri previousSessionUri)
Uploads a stream of data to this StorageReference The stream will remain open at the end of the upload.
ToString()
override string
Returns
This object in URI form, which can then be shared and passed into FirebaseStorage.GetReferenceFromUrl
UpdateMetadataAsync(MetadataChange metadata)
Updates the metadata associated with this StorageReference

Properties

Bucket

string Bucket

Return the Google Cloud Storage bucket that holds this object.

Details
Returns
the bucket.

Name

string Name

Returns the short name of this object.

Details
Returns
the name.

Parent

StorageReference Parent

Returns a new instance of StorageReference pointing to the parent location or null if this instance references the root location.

For example:


      path = foo/bar/baz   parent = foo/bar
      path = foo           parent = (root)
      path = (root)        parent = (null)
    

Details
Returns
the parent StorageReference

Path

string Path

Returns the full path to this object, not including the Google Cloud Storage bucket.

Details
Returns
the path.

Root

StorageReference Root

Returns a new instance of StorageReference pointing to the root location.

Details
Returns

Storage

FirebaseStorage Storage

Returns the FirebaseStorage service which created this reference.

Details
Returns
The FirebaseStorage service.

Public functions

Child

StorageReference Child(
  string pathString
)

Returns a new instance of StorageReference pointing to a child location of the current reference.

All leading and trailing slashes will be removed, and consecutive slashes will be compressed to single slashes. For example:


      child = /foo/bar     path = foo/bar
      child = foo/bar/     path = foo/bar
      child = foo///bar    path = foo/bar
    

Details
Parameters
pathString
The relative path from this reference.
Returns

DeleteAsync

Task DeleteAsync()

Deletes the object at this StorageReference

Details
Returns
A Task which can be used to monitor the operation and obtain the result.

Equals

override bool Equals(
  object other
)

Compares two storage reference URIs.

Details
Returns
true if two references point to the same path, false otherwise.

GetBytesAsync

Task< byte[]> GetBytesAsync(
  long maxDownloadSizeBytes
)

Downloads the object from this StorageReference A byte array will be allocated large enough to hold the entire file in memory.

Therefore, using this method will impact memory usage of your process. If you are downloading many large files, GetStream(StreamDownloadTask.StreamProcessor)

may be a better option.

Details
Parameters
maxDownloadSizeBytes
The maximum allowed size in bytes that will be allocated. Set this parameter to prevent out of memory conditions from occurring. If the download exceeds this limit, the task will fail and an System.IndexOutOfRangeException will be returned.