If you find any errors, typos or have general feedback, select the text and click CTRL+ALT+ENTER.

Introduction

The Files Upload plugin can help to implement file uploading in your Appery.io app. You can click “Choose File” to select needed files. They will appear as list on the page once you done. Then, you can upload all files by clicking “Upload all” or upload a single file by selecting it and clicking “Upload selected”.

The Appery.io database requires a sessionToken for uploading files to the database. To make the plugin simpler to use, it uses the Master Key. So, to configure this plugin, you should provide the ID of the database that will be used to store files and Master Key instead of sessionToken.

This plugin is configured out-of-the-box to work with the Appery.io database, but it can be modified to work with any other API provider that allows file upload. You will need to change the upload REST API and update any parameters.

Before you begin

  1. Tutorial level: intermediate.
  2. Prerequisites: An Appery.io account.

Creating an Appery.io app

Open Appery.io and click “Create new app,” enter any app name, and click “Create”.

Once the mobile editor loads, you’ll see a start page.

Importing the Upload File to Database plugin

  1. To import the plugin, click CREATE NEW > From Plugin.
  2. Check the box for the Files Upload plugin. Click “Import selected plug-ins”.
  3. Once the plugin is successfully installed, you will be asked to choose a default routing. Select Screen1_Apperyio_Files_Upload (Screen1 prefix can be different depends on your page name) as the default routing.

In the FileDB_settings, you should provide your database ID and Master Key. Go to https://appery.io/database/ and open the database that will be used to store the files. Go to the Settings tab and copy the API Key:
api_key

Paste it to database_id in FileUpload_settings. Also, copy the Master Key and paste it to the database_master_key:
filedb_settings

Running the app

That’s all you need to do. You can now run the app by clicking the “TEST” button or build the binary to test the app on the device.

Click “Choose Files” to browse for files in your file system. Select them and click “Open”. Files list will appear on the page.

Now you can upload all the files by clicking “Upload all”, or click on the certain file in the list and click “Upload selected” to upload the choose one.

Quirks

Valid file names

By default, plug-in logic doesn’t changes the original file name. However, Appery.io Database has some restriction to file names. Valid file name should contain only a-zA-Z0-9%_.- characters, and file name length is limited to 218 characters. You can change the file name on-the-fly in uploadSelected function at line number 14. For example:

Multiple upload response

While uploading multiple files at once, Appery.io backend will response success in case of any file have been successfully uploaded. That means, that if only one of several file has been uploaded successfully, you’ll get success as response. This behavior will be changed soon,