All Products
Search
Document Center

ApsaraDB RDS:Storage

Last Updated:Aug 26, 2026

RDS Supabase Storage manages your files through three core concepts: buckets, folders, and files. Store media files such as images and videos in Storage to reduce the load on your database, and manage them from the RDS Supabase console or the RDS Supabase SDK.

Terms

  • Bucket: The top-level container for files. Create separate buckets when files require different security or access rules. For example, use one bucket for public images and another for private user profiles.

  • Folder: Organizes files inside a bucket, the same way folders work on your computer.

  • File: Any media file, such as an image or a video. Storing these large files in Storage reduces the load on your database. For security reasons, HTML files are served as plain text.

    All bucket, folder, and file names must follow Alibaba Cloud OSS naming conventions. Avoid special characters.

Parameter settings

S3 backend configuration

RDS Supabase Storage includes a built-in Alibaba Cloud OSS backend, which is not visible to you. After you purchase RDS Supabase, you can use Storage directly. To use your own Alibaba Cloud OSS or another S3-compatible object storage service, configure the following parameters.

ParameterDescriptionFormat and notes
GLOBAL_S3_ENDPOINTThe endpoint of the OSS bucket
  • Must be a valid URL that starts with https://

  • Example: https://oss-cn-beijing.aliyuncs.com

GLOBAL_S3_BUCKETThe name of the OSS bucket
  • Must comply with OSS bucket naming rules

  • Example: beijing-supabase-test

REGIONThe region of the OSS bucket
  • Use the region code in lowercase

  • Example: cn-beijing

TENANT_IDThe OSS directory name. You do not need to create it.
  • We recommend that you use the Supabase project ID

  • Example: ra-supabase-xxx

AWS_ACCESS_KEY_IDThe AccessKey ID of the OSS bucket
  • Must comply with the AccessKey ID format

AWS_SECRET_ACCESS_KEYThe AccessKey secret of the OSS bucket
  • Must comply with the AccessKey secret format

AWS_SESSION_TOKEN(Optional) The temporary access token of the OSS bucket. If you leave this parameter empty, authentication uses the AccessKey ID and AccessKey secret.
  • Required only when you use temporary credentials such as STS

  • Can be omitted for long-term credentials

USE_DEFAULT_S3_BACKEND(Optional) Specifies whether to use the built-in OSS bucket
  • To use a custom OSS bucket, set this parameter to false or leave it blank. Do not set it to true. If a built-in Alibaba Cloud OSS bucket exists, it is released.

  • To use the default built-in Alibaba Cloud OSS bucket, set this parameter to true. If a custom OSS configuration exists, its parameters are cleared.

  • When you use a custom OSS configuration (USE_DEFAULT_S3_BACKEND=false), the backend releases the built-in Alibaba Cloud OSS bucket.

  • When you use the built-in Alibaba Cloud OSS bucket (USE_DEFAULT_S3_BACKEND=true), the backend clears the custom OSS configuration.

    Storage also provides the following general configuration parameter, which you can set separately:
ParameterDescriptionFormat and notes
FILE_SIZE_LIMITThe size limit of a single file, in bytes
  • A positive integer, in bytes

  • Example: 10485760 (= 10 MB)

S3 protocol configuration

Configure the S3 protocol to expose the S3 protocol endpoint of Storage. The endpoint is http(s)://<supabaseUrl>/storage/v1/s3. The region of the S3 protocol matches the region of the instance.

ParameterDescriptionFormat and notes
S3_PROTOCOL_ENABLEDSpecifies whether to enable S3 protocol connections
  • true or false

S3_PROTOCOL_ACCESS_KEY_ID(Optional) The ACCESS_KEY_ID used to access the S3 protocol endpoint
  • A string that contains only letters and digits

  • If you do not specify this parameter, the backend generates one at random

S3_PROTOCOL_ACCESS_KEY_SECRET(Optional) The ACCESS_KEY_SECRET used to access the S3 protocol endpoint
  • A string that contains only letters and digits

  • If you do not specify this parameter, the backend generates one at random

File storage

You can interact with Storage in either of the following ways:

  • RDS Supabase console: Provides a graphical interface for manual, visual file management. Choose the console to manage files manually.

  • RDS Supabase SDK: Provides programming interfaces to manage files automatically in an application, such as uploading user files or generating download links dynamically. Choose the SDK to integrate file operations into your application.

Manage files in the RDS Supabase console

Manage files in the RDS Supabase console

In the left sidebar of the RDS Supabase project console, select Storage to open the storage management page.

1. Create a bucket

When you use Storage for the first time, the page is empty. Create a bucket to store your files.

  1. On the Storage page, click New bucket.

  2. In the dialog box, enter a bucket name.

  3. Decide whether to make the bucket public (Public bucket).

    • Public bucket: All files in the bucket are accessible by URL. Use it for public resources such as website logos and CSS files.

    • Private bucket (default): Files in the bucket require authorization to access. Use it for sensitive data such as user profiles and order information.

  4. Click Create.

    You cannot change a bucket name after you create the bucket. Bucket type defaults to Standard bucket, which is S3-compatible. You can also configure Restrict file size to limit the size of uploaded files and Restrict MIME types to allow only specific file types.

2. Upload and manage files

  1. In the bucket list, click the bucket that you want to open.

  2. Click Create folder to organize your file structure.

  3. Click Upload files and select one or more files from your device.

  4. After the upload finishes, the files appear in the list. Hover over a file and click the ... menu on the right to Download, Get URL, Move, or Delete it.

Use the RDS Supabase SDK

Use the RDS Supabase SDK

Use the official JavaScript client library (@supabase/supabase-js) to integrate file operations into your application. The following sections describe file operations in pseudocode.

1. Initialize the client

Before you start, make sure that the supabase-js library is installed. Initialize the client with the project URL and the ServiceKey.

import { createClient } from '@supabase/supabase-js';
// Get the URL and ServiceKey from your Supabase project settings
const supabaseUrl = 'YOUR_SUPABASE_URL';
const supabaseServiceKey = 'YOUR_SUPABASE_SERVICE_KEY';
const supabase = createClient(supabaseUrl, supabaseServiceKey);

2. Create a bucket

Create a bucket named avatars.

// Use the JS library to create a bucket.
const { data, error } = await supabase.storage.createBucket('avatars');

3. Upload a file

Upload a file to the avatars bucket.

const avatarFile = event.target.files[0];
const { data, error } = await supabase.storage
  .from('avatars')
  .upload('public/avatar1.png', avatarFile);

4. Download a file

Download a specified file from the avatars bucket.

// Use the JS library to download a file. The complete sample code is as follows:

const { data, error } = await supabase.storage.from('avatars').download('public/avatar1.png');

Sample code

Sample code

import { createClient } from "@supabase/supabase-js";
const supabaseUrl = "YOUR_SUPABASE_URL";
const supabaseKey = "YOUR_SUPABASE_SERVICE_KEY";
const supabase = createClient(supabaseUrl, supabaseKey);
// Create a virtual text file for demonstration
const content = 'Hello, Supabase Storage!';
const blob = new Blob([content], { type: 'text/plain' });
const fileName = `public/avatar-${Date.now()}.txt`;
const bucketName = 'avatars';
async function storageExample() {
  try {
    // Step 1: Create a bucket named "avatars"
    // public: true indicates a public bucket
    // If the bucket already exists, Supabase returns the existing information without an error
    const { data: bucketData, error: bucketError } = await supabase.storage.createBucket(
      bucketName,
      {
        public: true, // Set as a public bucket
      }
    );
    if (bucketError && bucketError.message !== 'The resource already exists') {
      throw new Error(`Failed to create the bucket: ${bucketError.message}`);
    }
    console.log('Bucket created or confirmed:', bucketData || 'already exists');
    // Step 2: Upload a file to the "avatars" bucket
    const { data: uploadData, error: uploadError } = await supabase.storage
      .from(bucketName)
      .upload(fileName, blob, {
        cacheControl: '3600', // Cache policy
        upsert: false // Do not overwrite the file if it already exists
      });
    if (uploadError) {
      throw new Error(`Failed to upload the file: ${uploadError.message}`);
    }
    console.log('File uploaded successfully:', uploadData);
    // Step 3: Get the public URL of the uploaded file
    const { data: urlData } = supabase.storage
      .from(bucketName)
      .getPublicUrl(fileName);
    console.log('Public URL of the file:', urlData.publicUrl);
    // Other operations:
    // Download the file
    const { data: downloadData, error: downloadError } = await supabase.storage.from(bucketName).download(fileName);
    if (downloadError) {
      console.error('Failed to download the file:', downloadError.message);
    } else {
      console.log('File downloaded successfully:', downloadData);
    }
    // List all files in the bucket
    const { data: fileListData, error: fileListError } = await supabase.storage.from(bucketName).list();
    if (fileListError) {
      console.error('Failed to list the files:', fileListError.message);
    } else {
      console.log('Files in the bucket:', fileListData);
    }
  } catch (error) {
    console.error('Storage operation error:', error.message);
  }
}
// Run the sample function
storageExample();

Security policy settings

RDS Storage Policies are storage access control policies based on the PostgreSQL row-level security (RLS) mechanism. They provide fine-grained control over storage object permissions at the database level.

You can set security policies in the RDS Supabase console in either of the following ways. The Policies page suits quick configuration and most scenarios. The SQL Editor is for complex scenarios or batch operations.

Set policies manually on the Policies page

Set policies manually on the Policies page

This method guides you through policy creation in a graphical interface. You do not need to write complex SQL.

  1. In the left-side navigation pane of the RDS Supabase project console, choose Storage > Policies.

  2. In the bucket list on the Policies page, click New Policy.

  3. Select Get a policy from a template to use a preset storage template, or select Create a new policy from scratch for a fully custom configuration.

  4. On the policy configuration page, fill in the following fields:

    • Policy name: A descriptive name for the policy, such as Allow authenticated read access.

    • Allowed operation: The operation to allow, such as SELECT (download or list) or INSERT (upload).

    • Target roles: The roles that the policy applies to, such as authenticated (authenticated users).

    • Policy definition: The conditions that must be met for reads, updates, or deletes. For example, bucket_id = 'avatars' limits the policy to the bucket named avatars.

  5. Click Review to check the generated SQL statement. After you confirm it, click Save policy.

Configure policies in the SQL Editor

Configure policies in the SQL Editor

Run CREATE POLICY statements directly in the SQL Editor to create or modify policies.

Example 1: Allow public read access to a specified bucket

This policy allows anyone to read all files in the avatars bucket.

CREATE POLICY "Public read access for avatars"
ON storage.objects FOR SELECT
USING ( bucket_id = 'avatars' );

Example 2: Allow authenticated users to access only their own files

This policy combination ensures that users can upload, view, update, and delete only the files in their personal folder (path: /*).

-- Allow authenticated users to upload files to their own folder
CREATE POLICY "Allow authenticated uploads in user folder"
ON storage.objects FOR INSERT
TO authenticated
WITH CHECK(bucket_id = 'avatars' AND auth.uid()::text = (storage.foldername(name))[1]);
-- Allow authenticated users to read files in their own folder
CREATE POLICY "Allow authenticated reads in user folder"
ON storage.objects FOR SELECT
TO authenticated
USING(bucket_id = 'avatars' AND auth.uid()::text = (storage.foldername(name))[1]);

For more security policy settings, see the official Supabase storage security documentation.