Firebase storage upload files
  • 18 May 2022
  • 4 Minutes to read
  • Dark
    Light
  • PDF

Firebase storage upload files

  • Dark
    Light
  • PDF

Article Summary

Upload file(s) to Firebase Storage in the given upload path(s).

This flow function takes in a list of file objects - the file objects contain the upload path.

The first output is triggered if all of the files were uploaded successfully.

The second output is triggered if at least 1 of many files fail to upload.

The third output is triggered if all of the file uploads fail.

Note: Firebase needs to be initialized before this flow function can be used. Also, if access to the Firebase Storage resource is restricted make sure user is authenticated and has the required permissions to access it.

Input arguments

LabelKeyTypeRequired?DefaultDescription
Files to uploadfilesArrayYesList of files that have `uploadUrl` property.
Custom upload pathuploadPathStringNo

Custom path for uploaded files - this determines the folder structure in Firestore.

If custom path is not provided (No value from binding editor or undefined via formula), the folder structure will be copied from the device.

Note: that the custom upload and download paths need to match.

Output arguments

Number of outputs: 3

LabelKeyTypeDescription
Upload job IDjobIdNumberUnique job ID for the upload.
Uploaded filesfilesArrayObject describing the uploaded file.
  • Local path
files.pathStringAbsolute local filesystem path representing the file location on the device, including the filename and extension. On web, this is created via the [`createObjectURL`](https://developer.mozilla.org/en-US/docs/Web/API/URL/createObjectURL) method.
  • MIME type
files.mimeTypeStringMIME type of the file, if it could be determined.
  • Name
files.nameStringName of the file in the local filesystem, if applicable. Note that the filename and extension are included in the **Local path** property already.
  • Size
files.sizeNumberSize of the file, in bytes.
  • Created at
files.createdAtStringCreation datetime of the file, if it can be determined.
  • Modified at
files.modifiedAtStringDatetime when the file was last modified, if it can be determined.
  • Upload path
files.uploadPathStringFirebase Storage path where the file is uploaded
  • Upload status
files.uploadStatusObjectUpload status for the file
  • Download URL
files.downloadUrlStringURL to download the uploaded image. Depending on the Firebase configuration the URL is valid only temporarily and should be re-fetched using the Get Firebase Storage download URL flow function for later access.
Uploaded fileserroredFilesArrayObject describing the file for which the upload failed.
  • Local path
erroredFiles.pathStringAbsolute local filesystem path representing the file location on the device, including the filename and extension. On web, this is created via the [`createObjectURL`](https://developer.mozilla.org/en-US/docs/Web/API/URL/createObjectURL) method.
  • MIME type
erroredFiles.mimeTypeStringMIME type of the file, if it could be determined.
  • Name
erroredFiles.nameStringName of the file in the local filesystem, if applicable. Note that the filename and extension are included in the **Local path** property already.
  • Size
erroredFiles.sizeNumberSize of the file, in bytes.
  • Created at
erroredFiles.createdAtStringCreation datetime of the file, if it can be determined.
  • Modified at
erroredFiles.modifiedAtStringDatetime when the file was last modified, if it can be determined.
  • Upload path
erroredFiles.uploadPathStringFirebase Storage path where the file is uploaded
  • Upload status
erroredFiles.uploadStatusObjectUpload status for the file
  • Download URL
erroredFiles.downloadUrlStringURL to download the uploaded image. Depending on the Firebase configuration the URL is valid only temporarily and should be re-fetched using the Get Firebase Storage download URL flow function for later access.
Uploaded filessuccessfulFilesArrayObject describing the uploaded file.
  • Local path
successfulFiles.pathStringAbsolute local filesystem path representing the file location on the device, including the filename and extension. On web, this is created via the [`createObjectURL`](https://developer.mozilla.org/en-US/docs/Web/API/URL/createObjectURL) method.
  • MIME type
successfulFiles.mimeTypeStringMIME type of the file, if it could be determined.
  • Name
successfulFiles.nameStringName of the file in the local filesystem, if applicable. Note that the filename and extension are included in the **Local path** property already.
  • Size
successfulFiles.sizeNumberSize of the file, in bytes.
  • Created at
successfulFiles.createdAtStringCreation datetime of the file, if it can be determined.
  • Modified at
successfulFiles.modifiedAtStringDatetime when the file was last modified, if it can be determined.
  • Upload path
successfulFiles.uploadPathStringFirebase Storage path where the file is uploaded
  • Upload status
successfulFiles.uploadStatusObjectUpload status for the file
  • Download URL
successfulFiles.downloadUrlStringURL to download the uploaded image. Depending on the Firebase configuration the URL is valid only temporarily and should be re-fetched using the Get Firebase Storage download URL flow function for later access.

Events

LabelKeyDescriptionProperties
File upload progressonFileUploadProgressTriggered when the file upload progresses.jobId, totalSize, bytesUploaded, files

Errors

LabelCodeDescription
Unknown errorunknownThrown when trying to upload the files resulted in an unknown error.
All files failedallFilesFailedThrown if all of the files you are trying to upload fail
No files to uploadnoFilesToUploadThrown if there are no files to upload

Was this article helpful?