Skip to main content

Uploading files

Altogic has two core nodes shown below to upload files to its cloud storage. The first one uploads a single file and the second one uploads a list of files. They both accept file object(s) as input.

When you upload files to cloud storage, for each uploaded file, Altogic generates file metadata and stores this metadata information in its internal database. You can query file metadata information from the database using the Get File Metadata node.

File upload process

The uploaded files can be set as either public or private. If the public option is selected, the file metadata includes the publicPath information; otherwise, this information is not populated. Thus, you can directly access your public files using their public path (e.g., opening a browser and navigating to the public path link).

For public files, you can also specify how the file will be accessed through the browser, either inline or attachment. If the file is set as inline, then the file is displayed in the browser. If set as an attachment, then when you navigate to the file link, the file is downloaded.

The example below shows how to upload a file (e.g., user's profile image) to cloud storage. The file is provided as a named file object in the endpoint request body. We first get this file object from the request input, upload it to the cloud as a publicly accessible file and then return the file metadata as the response.

In the above example, we have returned the file metadata as the response. However, it is good practice to save profile image-related data to the user object so that when we fetch the user data, we also get the associated profile image information. In the below example, we update the user object, where the user id is provided as endpoint path parameter, set its profileImageId and profileImageURL field values using file metadata, and return the updated user object.