Skip to content

Commit 3c73856

Browse files
committed
address review comments part 1
1 parent 20fdc5d commit 3c73856

File tree

4 files changed

+41
-29
lines changed

4 files changed

+41
-29
lines changed
Binary file not shown.
Binary file not shown.
Binary file not shown.

docs/ff-concepts/file-handling/uploading-files.md

Lines changed: 41 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,7 @@ You can upload media to a **Supabase bucket** at a specified location. After the
3131

3232
### Local Upload (Widget State)
3333

34-
This method initially stores your media on the device, making it accessible via **Widget State > Uploaded Local File**. From there, you can do various things with the local file:
35-
36-
- **Preview or Validate the Media**: Show the user an in-app preview before deciding whether to finalize or discard the upload.
37-
- **Editing Before Submission**: Modify the file (e.g., apply filters to an image) before saving it to permanent storage.
38-
- **Perform Data Operations**: Access the file bytes (e.g., for compression, transformations, or further processing).
39-
- **Offline Functionality**: Store the media locally and defer uploading until the user regains internet access.
40-
- **Upload to Server**: When you want to store the file externally, you can then make an API call (e.g., multipart form data) to transfer the local file. Be sure to retrieve and save the resulting file URL if you plan to display it later.
41-
42-
By handling the media locally first, you gain flexibility—such as letting users confirm or edit an image—before making any final decisions on where to store or how to process it.
34+
This method initially stores your media on the device, making it accessible via **Widget State > Uploaded Local File**. You can preview, edit, or process the file before uploading it to a permanent storage.
4335

4436
![upload-type-local-and-api.avif](imgs/upload-type-local-and-api.avif)
4537

@@ -57,8 +49,7 @@ This action allows you to upload a photo or video to your app. You can choose to
5749

5850
:::info[Prerequisites for Supabase]
5951
1. Make sure to [**integrate Supabase**](../../ff-integrations/supabase/supabase-setup.md) into your app.
60-
2. [**Create a storage bucket**](https://supabase.com/docs/guides/storage/quickstart#create-a-bucket) in Supabase.
61-
**Tip**: To let anyone download the uploaded media, you can enable the 'Public bucket.'
52+
2. [**Create a storage bucket**](https://supabase.com/docs/guides/storage/quickstart#create-a-bucket) in Supabase. By default, the **Public bucket** option is disabled, meaning uploaded media is not accessible by anyone without authentication. If needed, you can enable the Public bucket option, but this is not recommended for sensitive content.
6253

6354
<p></p>
6455
![supabase-storage-bucket.png](imgs/supabase-storage-bucket.png)
@@ -114,6 +105,19 @@ When you set **Upload Type** to:
114105
</div>
115106
<p></p>
116107

108+
109+
The Upload Media action offers various settings to control how media files are uploaded, resized, and processed in your app. Below is a breakdown of all the available properties.
110+
111+
![configure-upload-media-action.avif](imgs/configure-upload-media-action.avif)
112+
113+
- **Max Width** and **Max Height**: If you are uploading a photo, you can set a maximum width and height using these properties. This resizes the image while maintaining its original aspect ratio.
114+
- **Image Quality**: Control the image quality by adjusting the slider or entering a value between 0 and 100, where 100 retains the original quality.
115+
- **Include Media Dimensions**: Enable this option to retrieve the dimensions (width and height) of the uploaded media. Keep in mind that this operation is resource-intensive, so enable it only if necessary.
116+
- **Include Blur Hash**: Automatically generates a BlurHash for the uploaded image, allowing you to display a blurred placeholder while the full image loads. For more information, refer to the [BlurHash](displaying-media.md#blurhash) section.
117+
- **Source Picker Style**: Customize the appearance of the bottom sheet UI that appears when selecting a media source (e.g., Camera or Gallery).
118+
- **Allow Multiple Images**: Enable this option to allow users to select multiple images. Note that this requires the **Media Source** to be set to **Gallery**. Once multiple images are uploaded, you can access their URLs via **Set from Variable menu > Widget State > Uploaded File URLs (`List<String>`)**.
119+
- **Show Snackbar**: Enable this option to notify users about the upload progress with a snackbar message.
120+
117121
Check out our YouTube video for a detailed explanation of the **Upload or Save Media [Action]** in FlutterFlow.
118122

119123
<div style={{
@@ -143,30 +147,29 @@ Check out our YouTube video for a detailed explanation of the **Upload or Save M
143147
<p></p>
144148

145149

146-
### Configure Upload or Save Media [Action]
150+
### Store Media for Upload
147151

148-
The Upload Media action offers various settings to control how media files are uploaded, resized, and processed in your app. Below is a breakdown of all the available properties.
152+
You can also save the media file temporarily on the device before uploading it to cloud storage by setting the **Upload Type** to [**Local Upload**](#local-upload-widget-state). This saves the file in Bytes, allowing you to preview, edit, or process it before finalizing the upload.
149153

150-
![configure-upload-media-action.avif](imgs/configure-upload-media-action.avif)
154+
Once the file is uploaded to the device, you can do various things with it:
151155

152-
- **Max Width** and **Max Height**: If you are uploading a photo, you can set a maximum width and height using these properties. This resizes the image while maintaining its original aspect ratio.
153-
- **Image Quality**: Control the image quality by adjusting the slider or entering a value between 0 and 100, where 100 retains the original quality.
154-
- **Include Media Dimensions**: Enable this option to retrieve the dimensions (width and height) of the uploaded media. Keep in mind that this operation is resource-intensive, so enable it only if necessary.
155-
- **Include Blur Hash**: Automatically generates a BlurHash for the uploaded image, allowing you to display a blurred placeholder while the full image loads. For more information, refer to the [BlurHash](displaying-media.md#blurhash) section.
156-
- **Source Picker Style**: Customize the appearance of the bottom sheet UI that appears when selecting a media source (e.g., Camera or Gallery).
157-
- **Allow Multiple Images**: Enable this option to allow users to select multiple images. Note that this requires the **Media Source** to be set to **Gallery**. Once multiple images are uploaded, you can access their URLs via **Set from Variable menu > Widget State > Uploaded File URLs (`List<String>`)**.
158-
- **Show Snackbar**: Enable this option to notify users about the upload progress with a snackbar message.
159-
160-
### Store Media for Upload
156+
- **Preview or Validate the Media**: Show the user an in-app preview before deciding whether to finalize or discard the upload.
161157

162-
You can also save the media file temporarily on the device before uploading it to cloud storage. This method is especially useful when you’re working with your own backend server, as it provides more control over the upload process.
158+
- **Editing Before Submission**: In social media apps, users upload photos for posts or stories. The app temporarily saves the image on the device while users edit or apply filters, and then uploads the final image to cloud storage.
159+
- **Perform Data Operations**: In document scanning apps, users capture images of documents, which are temporarily stored on the device. The app accesses the file bytes to apply OCR (Optical Character Recognition), enhance contrast, or convert the image to PDF before uploading the final processed file to cloud storage.
160+
- **Offline Functionality**: Store the media locally and defer uploading until the user regains internet access.
161+
- **Upload to Server**: When you want to store the file externally, you can then make an API call (e.g., multipart form data) to transfer the local file. Be sure to retrieve and save the resulting file URL if you plan to display it later.
163162

164-
For example, in social media apps, users upload photos for posts or stories. The app temporarily saves the image on the device while users edit or apply filters, and then uploads the final image to cloud storage.
163+
Here are some examples of uploading a file to a device and using it in different scenarios:
165164

166-
Here’s an example of how you can use this action to upload media to your server via an API:
165+
**Example 1: Upload to Your Backend Server via API**
167166

168167
First, set the **Upload/Save Media** action with the **Local Upload (Widget State)** upload type. Then, add the next action as an **API call** and select the API that will upload the file to your server. After the API call is complete, ensure your server returns the uploaded file's URL. Use this URL to save in the database or [display the uploaded image](displaying-media.md).
169168

169+
:::info
170+
The request body for the API must be in *Multipart* format. See how to [**configure an API for the multipart request body**](../../resources/control-flow/backend-logic/api/rest-api.md#multipart-format).
171+
:::
172+
170173

171174
<div style={{
172175
position: 'relative',
@@ -194,11 +197,20 @@ First, set the **Upload/Save Media** action with the **Local Upload (Widget Stat
194197
</div>
195198
<p></p>
196199

197-
:::info
200+
**Example 2: Compress Image Using Custom Action**
198201

199-
The request body for the API must be in *Multipart* format. See how to [**configure an API for the multipart request body**](../../resources/control-flow/backend-logic/api/rest-api.md#multipart-format).
202+
First, configure the **Upload/Save Media** action with the **Local Upload (Widget State)** upload type. This temporarily saves the media file on the device.
203+
204+
Next, create and add a [**Custom Action**](../../ff-concepts/adding-customization/custom-actions.md) (e.g., `compressImageAction`) that takes the locally stored file as input and compresses it using its **bytes** data. Ensure the custom action processes the image and returns a compressed file. Once compressed, the file can then be uploaded to cloud storage using another **Upload/Save Media** action.
205+
206+
![compress-image](imgs/compress-image.avif)
207+
208+
**Example 3: Upload to Firebase or Supabase**
209+
210+
First, configure the **Upload/Save Media** action with the **Local Upload (Widget State)** upload type. Once the file is modified or processed, add another **Upload/Save Media** action to the widget that confirms the final upload. Set the **Upload Type** to **Firebase** or **Supabase**, choose **File Type** as the **Uploaded File**, and select **File to Upload** from **Widget State > Uploaded Local File**.
211+
212+
![local-upload-to-firebase-supabase](imgs/local-upload-to-firebase-supabase.avif)
200213

201-
:::
202214

203215
## Upload or Save File [Action]
204216

0 commit comments

Comments
 (0)