Packagecom.myflashlab.air.extensions.firebase.storage
Classpublic class StorageReference
InheritanceStorageReference Inheritance flash.events.EventDispatcher

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.



Public Properties
 PropertyDefined By
  activeDownloadTasks : Array
[read-only] The Array of active download tasks currently in progress or recently completed.
StorageReference
  activeUploadTasks : Array
[read-only] The Array of active upload tasks currently in progress or recently completed.
StorageReference
  bucket : String
[read-only] Return the Google Cloud Storage bucket that holds this object.
StorageReference
  name : String
[read-only] Returns the short name of this object.
StorageReference
  parent : StorageReference
[read-only] Returns a new instance of StorageReference pointing to the parent location or null if this instance references the root location.
StorageReference
  path : String
[read-only] Returns the full path to this object, not including the Google Cloud Storage bucket.
StorageReference
  root : StorageReference
[read-only] Returns a new instance of StorageReference pointing to the root location.
StorageReference
Public Methods
 MethodDefined By
  
child($path:String):StorageReference
Returns a new instance of StorageReference pointing to a child location of the current reference.
StorageReference
  
getBytes($maxDownloadSizeBytes:Number, $onSuccess:Function, $onFailure:Function = null):void
Asynchronously downloads the object from this StorageReference A byte array will be allocated large enough to hold the entire file in memory.
StorageReference
  
getDownloadUrl($onSuccess:Function, $onFailure:Function = null):void
Asynchronously retrieves a long lived download URL with a revokable token.
StorageReference
  
getFile($destinationFile:File):FileDownloadTask
Asynchronously downloads the object at this StorageReference to a specified system filepath.
StorageReference
  
getMetadata($onSuccess:Function, $onFailure:Function = null):void
Retrieves metadata associated with an object at this StorageReference.
StorageReference
  
list($maxResults:int = 100, $pageToken:String, $onSuccess:Function = null, $onFailure:Function = null):void
The list() API places a limit on the number of results it returns.
StorageReference
  
listAll($onSuccess:Function, $onFailure:Function = null):void
You can use listAll to fetch all results for a directory.
StorageReference
  
putBytes($bytes:ByteArray, $metadata:StorageMetadata = null):UploadTask
Asynchronously uploads byte data to this StorageReference.
StorageReference
  
putFile($sourceFile:File, $metadata:StorageMetadata = null, $existingUploadUri:String = null):UploadTask
Asynchronously uploads a file to this StorageReference.
StorageReference
  
remove($onSuccess:Function, $onFailure:Function = null):void
Deletes the object at this StorageReference.
StorageReference
  
updateMetadata($metadata:StorageMetadata, $onSuccess:Function, $onFailure:Function = null):void
Updates the metadata associated with this StorageReference.
StorageReference
Property Detail
activeDownloadTasksproperty
activeDownloadTasks:Array  [read-only]

The Array of active download tasks currently in progress or recently completed.

NOTE: This is currently not available on the iOS side.


Implementation
    public function get activeDownloadTasks():Array
activeUploadTasksproperty 
activeUploadTasks:Array  [read-only]

The Array of active upload tasks currently in progress or recently completed.

NOTE: This is currently not available on the iOS side.


Implementation
    public function get activeUploadTasks():Array
bucketproperty 
bucket:String  [read-only]

Return the Google Cloud Storage bucket that holds this object.


Implementation
    public function get bucket():String
nameproperty 
name:String  [read-only]

Returns the short name of this object.


Implementation
    public function get name():String
parentproperty 
parent:StorageReference  [read-only]

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


Implementation
    public function get parent():StorageReference
pathproperty 
path:String  [read-only]

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


Implementation
    public function get path():String
rootproperty 
root:StorageReference  [read-only]

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


Implementation
    public function get root():StorageReference
Method Detail
child()method
public function child($path:String):StorageReference

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
		 

Parameters

$path:String

Returns
StorageReference
getBytes()method 
public function getBytes($maxDownloadSizeBytes:Number, $onSuccess:Function, $onFailure:Function = null):void

Asynchronously 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, getFile() may be a better option.

Parameters

$maxDownloadSizeBytes:Number — 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.
 
$onSuccess:Function — Will be called on a successful operation. You must accept a StorageEvents as the input parameter so you will have access to the downloaded bytes via event.bytes
 
$onFailure:Function (default = null) — Will be called if the operation fails. You must accept a StorageEvents as the input parameter so you will have access to the event.errorCode and event.msg

getDownloadUrl()method 
public function getDownloadUrl($onSuccess:Function, $onFailure:Function = null):void

Asynchronously retrieves a long lived download URL with a revokable token. This can be used to share the file with others, but can be revoked by a developer in the Firebase Console if desired.

Parameters

$onSuccess:Function — Will be called on a successfull operation. You must accept a StorageEvents as the input parameter so you will have access to the downloaded bytes via event.url
 
$onFailure:Function (default = null) — Will be called if the operation fails. You must accept a StorageEvents as the input parameter so you will have access to the event.errorCode and event.msg

getFile()method 
public function getFile($destinationFile:File):FileDownloadTask

Asynchronously downloads the object at this StorageReference to a specified system filepath.

NOTICE: THIS FEATURE IS ONLY AVAILABLE TO MYFLASHLABS CLUB MEMBERS: You may use this method to download big files from Firebase Storage but if you're not a club member, you can use the getBytes() method instead for small files. However by Joining the club, you are supporting the MyFlashLabs Team to be able to do their job with more ease.

Parameters

$destinationFile:File — A File representing the path the object should be downloaded to.

Returns
FileDownloadTask — A FileDownloadTask that can be used to monitor or manage the download.
getMetadata()method 
public function getMetadata($onSuccess:Function, $onFailure:Function = null):void

Retrieves metadata associated with an object at this StorageReference.

Parameters

$onSuccess:Function — Will be called on a successfull operation. You must accept a StorageEvents as the input parameter so you will have access to the downloaded bytes via event.metadata
 
$onFailure:Function (default = null) — Will be called if the operation fails. You must accept a StorageEvents as the input parameter so you will have access to the event.errorCode and event.msg

list()method 
public function list($maxResults:int = 100, $pageToken:String, $onSuccess:Function = null, $onFailure:Function = null):void

The list() API places a limit on the number of results it returns. list() provides a consistent pageview and exposes a pageToken that allows control over when to fetch additional results. The pageToken encodes the path and version of the last item returned in the previous result. In a subsequent request using the pageToken, items that come after the pageToken are shown.

Parameters

$maxResults:int (default = 100)
 
$pageToken:String
 
$onSuccess:Function (default = null) — Will be called on a successfull operation. You must accept a StorageEvents as the input parameter so you will have access to the downloaded bytes via event.url
 
$onFailure:Function (default = null) — Will be called if the operation fails. You must accept a StorageEvents as the input parameter so you will have access to the event.errorCode and event.msg

listAll()method 
public function listAll($onSuccess:Function, $onFailure:Function = null):void

You can use listAll to fetch all results for a directory. This is best used for small directories as all results are buffered in memory. The operation also may not return a consistent snapshot if objects are added or removed during the process.

Parameters

$onSuccess:Function — Will be called on a successfull operation. You must accept a StorageEvents as the input parameter so you will have access to the downloaded bytes via event.url
 
$onFailure:Function (default = null) — Will be called if the operation fails. You must accept a StorageEvents as the input parameter so you will have access to the event.errorCode and event.msg

putBytes()method 
public function putBytes($bytes:ByteArray, $metadata:StorageMetadata = null):UploadTask

Asynchronously uploads byte data to this StorageReference. This is not recommended for large files. Instead upload a file via putFile().

Parameters

$bytes:ByteArray — The ByteArray to upload.
 
$metadata:StorageMetadata (default = null) — StorageMetadata containing additional information (MIME type, etc.) about the object being uploaded.

Returns
UploadTask — An instance of UploadTask which can be used to monitor and manage the upload.
putFile()method 
public function putFile($sourceFile:File, $metadata:StorageMetadata = null, $existingUploadUri:String = null):UploadTask

Asynchronously uploads a file to this StorageReference.

Important: If the $existingUploadUri parameter is set, you cannot leave the $metadata parameter null

NOTE: The $existingUploadUri feature is not supported on iOS yet. We hope Firebase will add it soon. https://github.com/firebase/quickstart-ios/issues/89

NOTICE: THIS FEATURE IS ONLY AVAILABLE TO MYFLASHLABS CLUB MEMBERS: You may use this method to upload big files to Firebase Storage but if you're not a club member, you can use the putBytes() method instead for small files. However by Joining the club, you are supporting the MyFlashLabs Team to be able to do their job with more ease.

Parameters

$sourceFile:File — The source of the upload.
 
$metadata:StorageMetadata (default = null) — StorageMetadata containing additional information (MIME type, etc.) about the object.
 
$existingUploadUri:String (default = null) — If set, an attempt is made to resume an existing upload session.

Returns
UploadTask
remove()method 
public function remove($onSuccess:Function, $onFailure:Function = null):void

Deletes the object at this StorageReference.

Parameters

$onSuccess:Function — Will be called on a successfull operation. You must accept a StorageEvents as the input parameter.
 
$onFailure:Function (default = null) — Will be called if the operation fails. You must accept a StorageEvents as the input parameter so you will have access to the event.errorCode and event.msg

updateMetadata()method 
public function updateMetadata($metadata:StorageMetadata, $onSuccess:Function, $onFailure:Function = null):void

Updates the metadata associated with this StorageReference.

known bug: Calling this method on Android Ice cream sandwich will fail! We have reported the issue to Google. You may follow up the conversation here: https://github.com/firebase/quickstart-android/issues/118

Parameters

$metadata:StorageMetadata — A StorageMetadata object with the metadata to update.
 
$onSuccess:Function — Will be called on a successful operation. You must accept a StorageEvents as the input parameter so you will have access to the downloaded bytes via event.metadata
 
$onFailure:Function (default = null) — Will be called if the operation fails. You must accept a StorageEvents as the input parameter so you will have access to the event.errorCode and event.msg