Development Guides
SDK
File Handling

File handling

Introduction

The SDK for ROQ Backend-as-a-Service (BaaS) for file handling provides client applications with APIs and services to handle, store, retrieve, and manipulate files on remote servers without developers needing to build and maintain their backend infrastructure. Hence, makes it easier for developers to build without too much thinking about file handling.

The SDK for ROQ BaaS provides a complete solution for file management, including these features:

  • File upload.
  • File management (create, read, update, and delete files).
  • Files visibility (public or private).
  • File categories.

You can utilize all of these features through an API, and you can also configure files using the ROQ Console.

Code examples

All file-handling APIs on the client side are live by default in the /lib/roq folder, and all file-handling APIs are accessible through the ROQ client roqBrowserClient.

The front-end SDK provides the necessary API for file handling on the client side, such as uploading files, changing file visibility, getting file categories, deleting files, or updating existing files. The API can be used with any supporting JavaScript framework.

To use these APIs, you need to import it first.

import { roqBrowserClient } from '@/lib/roq/roq-client';

And because file handling APIs are ROQ platform features, they live not in specific entities but in the ROQ platform.

Let's take an example of how to list all uploaded files:

import { roqBrowserClient } from '@/lib/roq/roq-client';
 
const getFiles = async () => {
  return await roqBrowserClient.roqPlatform.files({})
}

For more about File API, please refer to the Files documentation section. It covers the file upload process as well as how to use API.

Framework integration

ROQ SDK, for the client side, can be integrated into various web frameworks like Next.js, Nuxt.js, RedwoodJS, and SvelteKit. For a practical example of file upload using Next.js, please read the documentation on add file uploads.