- 18 May 2022
- 4 Minutes to read
- DarkLight
- PDF
Firebase storage upload files
- Updated on 18 May 2022
- 4 Minutes to read
- DarkLight
- PDF
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
Label | Key | Type | Required? | Default | Description |
---|---|---|---|---|---|
Files to upload | files | Array | Yes | List of files that have `uploadUrl` property. | |
Custom upload path | uploadPath | String | No | – | Custom path for uploaded files - this determines the folder structure in Firestore. |
Output arguments
Number of outputs: 3
Label | Key | Type | Description |
---|---|---|---|
Upload job ID | jobId | Number | Unique job ID for the upload. |
Uploaded files | files | Array | Object describing the uploaded file. |
| files.path | String | Absolute 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. |
| files.mimeType | String | MIME type of the file, if it could be determined. |
| files.name | String | Name of the file in the local filesystem, if applicable. Note that the filename and extension are included in the **Local path** property already. |
| files.size | Number | Size of the file, in bytes. |
| files.createdAt | String | Creation datetime of the file, if it can be determined. |
| files.modifiedAt | String | Datetime when the file was last modified, if it can be determined. |
| files.uploadPath | String | Firebase Storage path where the file is uploaded |
| files.uploadStatus | Object | Upload status for the file |
| files.downloadUrl | String | URL 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 files | erroredFiles | Array | Object describing the file for which the upload failed. |
| erroredFiles.path | String | Absolute 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. |
| erroredFiles.mimeType | String | MIME type of the file, if it could be determined. |
| erroredFiles.name | String | Name of the file in the local filesystem, if applicable. Note that the filename and extension are included in the **Local path** property already. |
| erroredFiles.size | Number | Size of the file, in bytes. |
| erroredFiles.createdAt | String | Creation datetime of the file, if it can be determined. |
| erroredFiles.modifiedAt | String | Datetime when the file was last modified, if it can be determined. |
| erroredFiles.uploadPath | String | Firebase Storage path where the file is uploaded |
| erroredFiles.uploadStatus | Object | Upload status for the file |
| erroredFiles.downloadUrl | String | URL 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 files | successfulFiles | Array | Object describing the uploaded file. |
| successfulFiles.path | String | Absolute 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. |
| successfulFiles.mimeType | String | MIME type of the file, if it could be determined. |
| successfulFiles.name | String | Name of the file in the local filesystem, if applicable. Note that the filename and extension are included in the **Local path** property already. |
| successfulFiles.size | Number | Size of the file, in bytes. |
| successfulFiles.createdAt | String | Creation datetime of the file, if it can be determined. |
| successfulFiles.modifiedAt | String | Datetime when the file was last modified, if it can be determined. |
| successfulFiles.uploadPath | String | Firebase Storage path where the file is uploaded |
| successfulFiles.uploadStatus | Object | Upload status for the file |
| successfulFiles.downloadUrl | String | URL 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
Label | Key | Description | Properties |
---|---|---|---|
File upload progress | onFileUploadProgress | Triggered when the file upload progresses. | jobId, totalSize, bytesUploaded, files |
Errors
Label | Code | Description |
---|---|---|
Unknown error | unknown | Thrown when trying to upload the files resulted in an unknown error. |
All files failed | allFilesFailed | Thrown if all of the files you are trying to upload fail |
No files to upload | noFilesToUpload | Thrown if there are no files to upload |