Skip to content

Commit a9df82f

Browse files
pufPoojaB26
andauthored
Puf - add docs for (enhanced) Firebase storage library (#346)
* Create storage-library.md First commit of documentation for the Firebase Storage library. * Extract inline image into file Extract inline image into file in the right location and then link it there. I included both the original png and a derived svg in there, but am linking only the svg from the markdown as that one renders more readably. * Update storage-library.md Remove image as one was too vague and the other too different. The same info is in the descriptions of the custom actions also. * update formatting * Remove unused files --------- Co-authored-by: PoojaB26 <[email protected]>
1 parent de3814d commit a9df82f

File tree

1 file changed

+104
-0
lines changed

1 file changed

+104
-0
lines changed
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
---
2+
slug: /integrations/firebase-storage/storage-library
3+
title: Firebase Storage Library
4+
description: The Firebase Storage Library provides access to the files in Cloud Storage through the Firebase SDK beyond what FlutterFlow's built-in support provides.
5+
tags: [Firebase Storage, Cloud Storage, Integration, Library]
6+
sidebar_position: 2
7+
keywords: [FlutterFlow, Firebase Storage, Cloud Storage, Integration, Security]
8+
---
9+
10+
The [Firebase Storage Library][storage-library-item] provides access to the files in Cloud Storage through the Firebase SDK beyond what [FlutterFlow's built-in support](/concepts/file-handling) provides.
11+
12+
13+
[storage-library-item]: https://marketplace.flutterflow.io/item/Ec3NWw8sxqJ1tbriOIEE
14+
15+
## Instructions
16+
17+
To start using this library:
18+
19+
1. [Import the library](/resources/projects/libraries/#importing-a-library) into your existing FlutterFlow project.
20+
2. [Connect your FlutterFlow project to Firebase](/integrations/firebase/connect-to-firebase/) (if you haven't done so already).
21+
The library will default to using the default bucket of your associated Firebase project. You can override this behavior by passing an explicit bucket URL to any of the actions.
22+
3. [Use the Custom Actions](/concepts/custom-code/custom-actions/#using-a-custom-action) and Custom Functions in your Action Flows.
23+
24+
25+
### Custom actions
26+
27+
* `uploadFileToBucket` \- Upload a file to any path in any bucket that you have write access to.
28+
* **Parameters:**
29+
* The `bucketName` (`String?`) to upload the file to. If you leave this empty, it uses the default bucket of the associated Firebase project.
30+
* The `fullPath` (`String?`) where the file will be written to inside the bucket. If this is specified, the `prefix` parameter is ignored.
31+
* The `uploadedFile` (`FFUploadedFile`) that is to be uploaded to Cloud Storage. This is the action output of a previous `Store media for upload` action.
32+
* The `prefix` (folder/directory) (`String?`) where the file will be uploaded to. If `fullPath` is not specified, the action uses this parameter and the `name` of the `uploadedFile` to determine the full path where it writes the file.
33+
* **Action result:**
34+
* If successful, the action result is a `fileObject` containing the full path of the uploaded file.
35+
36+
* `listAllFilesInBucket` \- List all files in any bucket that you have read access to.
37+
* **Parameters:**
38+
* The `bucketName` (`String?`) to list the files from. If you leave this empty, it uses the default bucket of the associated Firebase project.
39+
* The `listType` (`StorageListType?`) of the items to list (files, directories, both). If left empty, the action will list both files and prefixes (folders/directories).
40+
* The `prefix` (`String?`) is the `/` separated path from which to list files. If left empty, the action will list the items in the root of the storage bucket.
41+
* **Action result:**
42+
* If successful, the action results in a `List` of `fileObject` elements.
43+
44+
* `downloadFile` \- Download the data for a file that you have read access to. This downloads the actual data into your application code. If you instead want a public URL to the data, use `getDownloadUrl` instead.
45+
* **Parameters:**
46+
* The `bucketName` (`String?`) to download the file from. If you leave this empty, it uses the default bucket of the associated Firebase project.
47+
* The `fullPath` (`String`) of the file whose data will be read from the bucket.
48+
* **Action result:**
49+
* If successful, the action result is an `FFUploadedFile` with the data of the file that was read from the bucket.
50+
51+
* `getDownloadUrl` \- Get the download URL for a file in a bucket that you have read access to. This URL then provides public, read-only access to the file
52+
* **Parameters:**
53+
* The `bucketName` (`String?`) that contains the file. If you leave this empty, it uses the default bucket of the associated Firebase project.
54+
* The `fullPath` (`String`) of the file for which to get the download URL.
55+
* **Action result:**
56+
* If successful, the action result is a HTTP URL that allows public access to the file.
57+
58+
* `getMetadataForFile` \- Get the metadata for a file in any bucket that you have read access to
59+
* **Parameters:**
60+
* The `bucketName` (`String?`) that contains the file. If you leave this empty, it uses the default bucket of the associated Firebase project.
61+
* The `fullPath` (`String`) of the file for which to get the download URL.
62+
* A**ction result:**
63+
* If successful, the action result is a `FullMetadata` with all the metadata and custom metadata of the file.
64+
65+
66+
* `updateMetadataForFile` \- Update the metadata for a file in any bucket that you have write access to
67+
* **Parameters:**
68+
* The `bucketName` (`String?`) that contains the file. If you leave this empty, it uses the default bucket of the associated Firebase project.
69+
* The `fullPath` (`String`) of the file for which to get the download URL.
70+
* The `metadata` (`SettableMetadata`) to write to the Cloud Storage bucket for the file. If any value is left out or empty in the metadata, it is left unmodified in Cloud Storage.
71+
* **Action result:**
72+
* If successful, the action result is a `FullMetadata` with all the metadata and custom metadata of the file after the update.
73+
74+
75+
* `getPathFromUrl` \- Get the path for a file based on its (https:// or gs://) URL. This is a synchronous call, as it doesn't require any call to the server.
76+
* **Parameters**
77+
* The `Url` to parse.
78+
* **Action result:**
79+
* The action result is a `fileObject` derived from the URL.
80+
81+
* `deleteFileFromBucket` \- Deletes a file from any bucket you have write access to.
82+
* **Parameters:**
83+
* The `bucketName` (`String?`) that contains the file. If you leave this empty, it uses the default bucket of the associated Firebase project.
84+
* The `fullPath` (`String`) of the file to delete from the bucket.
85+
* **Action result:**
86+
* If the action succeeds the file has been deleted. There is no additional information.
87+
88+
### Enums
89+
90+
* `StorageListType` is an enumeration of the types of items that the `listAllFilesInBucket` action can return. Values:
91+
* `files`: List only the files in the specified path.
92+
* `prefixes`: List only the prefixes in the specified path. You might more commonly refer to these as folders or directories, but since Cloud Storage doesn't actually have support for folders/directories, it uses `/` characters in the file names to emulate those and calls them prefixes.
93+
* `filesAndPrefixes`: List both files and prefixes in the specified path.
94+
95+
### Data Types
96+
97+
* `fileObject` \- the metadata for a file or prefix (folder/directory) in Cloud Storage. It has the following fields:
98+
* `fullPath` (`String`) \- The full path of the file/prefix inside the storage bucket. The value does not start with a leading `/`.
99+
* `isPrefix` (`Boolean`) \- Indicates whether the object is a file (`false`) or prefix (folder/directory) (`true`).
100+
101+
102+
* `FullMetadata` \- the full metadata of an item in a storage bucket as returned by `getMetadataForFile`, modelled after the [`FullMetadata` class in the Firebase SDK for Cloud Storage](https://pub.dev/documentation/firebase_storage/latest/firebase_storage/FullMetadata-class.html).
103+
* `SettableMetadata` \- the settable metadata of an item in a storage bucket, as passed to a call to `updateMetadataForFile`, modelled after the [`SettableMetadata` class in the Firebase SDK for Cloud Storage](https://pub.dev/documentation/firebase_storage/latest/firebase_storage/SettableMetadata-class.html).
104+
* `KeyValuePair` \- A `String`/`String` key/value pair as used for the `customMetadata` in the `FullMetadata` and `SettableMetadata` data types.

0 commit comments

Comments
 (0)