Create file object
The Create file object action node adds files into a data source based on a file object class. For static files used in your apps, see Files.
Usage
This action node is used to create a new file object containing a file and associated metadata. To understand the differences in behavior when creating an object in a database-connected data source compared to a runtime-only data source, see Database-connected and runtime-only data sources under Data sources.
A file can be added from several sources:
The file system of a client user's computer or mobile device.
The camera on a client user's mobile device (image or video).
A URL.
A string or blob.
When uploading files from the file system, the action node supports multiple simultaneous uploads using the Max Selectable Files property. This allows a client user to select multiple files in the file browser, or to drag and drop multiple files on a container configured for file drop.
Images can be resized (with Max Image Size) and compressed (with Compress Image) on upload in order to control file sizes. When these features are enabled, images will be converted to JPEG format. Transparency is not supported and any transparent parts of an image will become black.
By default, files in a file object require authentication to access. If required, a file can be made available for public distribution to unauthenticated users by selecting the Public property.
When adding a file from a URL, both public and authenticated URLs are supported. Secrets can be used in either the URL or a request header by selecting the Run on Server property.
Is the file browser or camera not opening?
The Create File action node, with Source Type Default (opening the file browser or device camera on your phone), is in some cases required to be the first action node of the action in order for the browser to interpret the operation as "user-initiated". This has been seen in Safari on iPhone. The solution is to move the Create File Object as the first action node, and then do additional logic.
Properties
Property | Description |
---|---|
Data Source | Select a data source based on a file object class to create the object in. |
Source Type | Select the source of the file.
|
Max Selectable Files | Available when Selection is Default. Set a maximum number of files that can be uploaded in one operation. If a user attempts to upload more than this number, an error will be thrown. Default is 1. |
Accepted File Types | Available when Selection is Default. Select the file types that are supported in the app. This will be used in the file browser to highlight accepted file types. If a user attempts to upload an unaccepted file type, an error will be thrown. By default, all file types are accepted. |
Max Image Size | Available when Selection is Default and Accepted File Types includes Image. Set a maximum size in pixels that will be applied to an image when it is uploaded. If an image exceeds this size, it will be resized to the maximum. When a value is set for this property, all images will be converted to JPEG format. Transparency is not supported and any transparent parts of the image will become black. |
Compress Image | Available when Selection is Default and Accepted File Types includes Image. Apply compression to the image when it is uploaded. This process converts images to JPEG format. Transparency is not supported and any transparent parts of the image will become black. |
Use Device Camera | Available when Selection is Default and Accepted File Types includes Image or Video. Launch the camera on a mobile device instead of the file browser. On computers, the file browser will be opened. |
URL | Available when Selection is URL. Set the URL where the file is located. |
Request Headers | Available when Selection is URL. Add request headers if any are required to fetch the file from the URL. |
Run On Server | |
Replace Existing Object | Available if the selected Data Source is a single-cardinality data source. Remove any existing object in the selected Data Source before the new object is created. |
Set Selected | Set the newly created objects as selected. |
Public | Make the file available for public distribution to unauthenticated users. Additionally, this option can be useful when you don't want the File Content URL of a persisted file object to expire. |
Custom File Content | Available when Selection is Custom. Set a string or blob to use as the contents of the file. |
File Name | Available unless Max Selectable Files is greater than 1. Set a file name that will be applied if the file is downloaded by a user. This value is stored in the object class property Original File Name. |
Mime Type | Available when Selection is Custom. Set a MIME type (media type) for a custom file. |
Values on create | Set values for any object class properties in the new object. |
Last updated