Supabase.Storage.BucketHandler (supabase_storage v0.3.0)

Provides low-level API functions for managing Supabase Storage buckets.

The BucketHandler module offers a collection of functions that directly interact with the Supabase Storage API for managing buckets. This module works closely with the Supabase.Fetcher for sending HTTP requests.

Features

  • Bucket Listing: Fetch a list of all the buckets available in the storage.
  • Bucket Retrieval: Retrieve detailed information about a specific bucket.
  • Bucket Creation: Create a new bucket with specified attributes.
  • Bucket Update: Modify the attributes of an existing bucket.
  • Bucket Emptying: Empty the contents of a bucket without deleting the bucket itself.
  • Bucket Deletion: Permanently remove a bucket and its contents.

Caution

This module provides a low-level interface to Supabase Storage buckets and is designed for internal use by the Supabase.Storage module. Direct use is discouraged unless you need to perform custom or unsupported actions that are not available through the higher-level API. Incorrect use can lead to unexpected results or data loss.

Implementation Details

All functions within the module expect a base URL, API key, and access token as their initial arguments, followed by any additional arguments required for the specific operation. Responses are usually in the form of {:ok, result} or {:error, message} tuples.

Summary

Types

@type bucket_id() :: String.t()
Link to this type

bucket_name()

@type bucket_name() :: String.t()
Link to this type

create_attrs()

@type create_attrs() :: %{
  id: String.t(),
  name: String.t(),
  file_size_limit: integer() | nil,
  allowed_mime_types: [String.t()] | nil,
  public: boolean()
}
Link to this type

update_attrs()

@type update_attrs() :: %{
  public: boolean() | nil,
  file_size_limit: integer() | nil,
  allowed_mime_types: [String.t()] | nil
}

Functions

Link to this function

create(client, attrs)

@spec create(Supabase.Client.t(), create_attrs()) ::
  {:ok, Supabase.Storage.Bucket.t()} | {:error, String.t()}
Link to this function

delete(client, id)

@spec delete(Supabase.Client.t(), bucket_id()) ::
  {:ok, String.t()} | {:error, String.t()}
Link to this function

empty(client, id)

@spec empty(Supabase.Client.t(), bucket_id()) ::
  {:ok, :successfully_emptied} | {:error, String.t()}
@spec list(Supabase.Client.t()) ::
  {:ok, [Supabase.Storage.Bucket.t()]} | {:error, String.t()}
Link to this function

retrieve_info(client, bucket_id)

@spec retrieve_info(Supabase.Client.t(), String.t()) ::
  {:ok, Supabase.Storage.Bucket.t()} | {:error, String.t()}
Link to this function

update(client, id, attrs)

@spec update(Supabase.Client.t(), bucket_id(), update_attrs()) ::
  {:ok, Supabase.Storage.Bucket.t()} | {:error, String.t()}