Files Blocks

Advanced Blocks

For most blocks in this drawer, you can right-click the block and select Show advanced block to see an expanded block with additional outputs. Both the simple and advanced blocks will be explained in this document.

Block: Image/Video from Photo Library

This block will open the user's photo library and allow the user to select a photo or video. The file can then be used in the app.

Advanced Block

OutputData TypeFunction

photo or video

image/video

if a file was selected, returns the file

was cancelled

true/false

returns whether the user cancelled selecting a file

error

text

if there was an error, returns the error

Block: File from Device

This block will open the user's file library and allow the user to select a file. The file can then be used in the app.

You can allow the user to upload any kind of file, or limit their selection by file type using the drop down menu.

Your end users may experience lags or delays if the file size they try to upload is larger than 5MB.

Advanced Block

OutputDescriptionData Type

file

Points to the file that has been uploaded

Data type of the file that has been uploaded. Can also return address of the file as text

name

Name of the uploaded file

Text

mime type

Describes the type of file in MIME format

Text

size

Returns size of uploaded file in bytes

Number

was cancelled

Indicates whether the end user cancelled selecting a file

True/False

error

If there is an error, returns the error. Else returns null

Text

Upload a File to the Cloud

Thunkable integrates with Cloudinary, a service that allows you to store media files in the cloud. The upload file block allows you to send media directly from your Thunkable app to a linked Cloudinary account.

Video Tutorial

How to Store and Access Cloudinary Files in Your Thunkable App

In this tutorial, you’ll learn how to use files stored in Cloudinary in your app and how to upload files directly from your app to Cloudinary.

Connect Your Cloudinary Account to Your Thunkable Project

Thunkable provides a shared Cloudinary account for your convenience, but we strongly recommend creating your own account to ensure privacy for your uploaded media. In addition, the shared Thunkable Cloudinary account has a media size limit of 10MB per app and your files will be deleted after 90 days.

To connect your Cloudinary accout to your Thunkable project:

  1. Create a free Cloudinary account here: cloudinary.com.

  2. From your Cloudinary dashboard, retrieve the following account details:

    1. Cloud Name

    2. API Key

    3. API Secret

  3. Return to your Thunkable project page.

  4. Scroll down until you reach the Cloudinary Settings section.

Block: url from uploaded file / upload file

Advanced Block

OutputData TypeFunction

URL

text

returns a URL for the uploaded file

error

text

if there was an error, returns the error

To see an example of the url from uploaded file block in action, check out this video tutorial: How to Create Data in a Thunkable Data Source.

Block: Resize Image

This block will take an image file and return it in the given dimensions, quality and format.

Advanced Block

InputData TypeFunction

resize image

Any image file

The image to be resized

width

Number

Width in pixels to resize image file to

height

Number

Height in pixels to resize image file to

quality

Number

Quality of resulting image, as a percentage of quality of original image

using ... format

Select from menu

Select image type for resulting image

OutputData TypeFunction

resized Image

Image

The resized image in the selected format and quality level

error

Text

If there was an error, returns the error. Else returns NULL

Download A File Within Your App

The Download File within app blocks enable your app's users to download files used in your app on request, ensuring a better offline user experience.

Block: Download File from URL

This block allows you to download a file from a URL onto your device. This file cannot be accessed from outside the app.

Advanced Block

OutputData TypeFunction

file

Text

Returns a file name and extension for the downloaded file.

progress

number

Returns the progress of the downloaded file.

error

Text

If there was an error, returns the error. Else returns NULL

The file type in the URL must be the same type as the type on the file name. Downloaded files cannot be accessed outside of the app (e.g. device files, photo gallery, etc.).

Block: Get Downloaded Files

This block returns the list of files that you have already downloaded.

Advanced Block

OutputData TypeFunction

files

Text

Returns a list of file names and extensions for the downloaded files.

error

Text

If there was an error, returns the error. Else returns NULL

Block: Delete Downloaded File

This block deletes the file that you have downloaded from your local storage.

Advanced Block

OutputData TypeFunction

error

Text

If there was an error, returns the error. Else returns NULL

Block: Rename Downloaded File

This block renames a previously downloaded file from your local storage.

Advanced Block

OutputData TypeFunction

error

Text

If there was an error, returns the error. Else returns NULL

Last updated