supabase-rb-rb
Storage

Update a bucket

Patch a bucket's public flag, size limit, or allowed MIME types.

Patch a bucket's public flag, file_size_limit, or allowed_mime_types. Pass only the fields you want to change — nil (or omitting the keyword) leaves the existing value untouched.

The bucket id is immutable. To rename a bucket, you'd have to create_bucket a new id, copy objects across, and delete_bucket the old one.

Service-role key required

Bucket admin endpoints reject the publishable / anon key with 401 Unauthorized. Construct the client with the service-role JWT.

Signature

supabase.storage.update_bucket(id,public: nil,file_size_limit: nil,allowed_mime_types: nil)

Parameters

NameTypeRequiredDescription
idStringRequiredBucket identifier to update.
publicBooleanOptionalFlip the bucket between public (anonymous reads allowed) and private. Omit to leave unchanged.
file_size_limitIntegerOptionalNew maximum object size in bytes. Omit to leave unchanged. Pass 0 only if you genuinely want a zero-byte ceiling.
allowed_mime_typesArray<String>OptionalNew MIME-type allowlist. Omit to leave unchanged. Pass an empty array only if you want to forbid every upload.

Returns

Returns
Hash

The raw storage-api response body, typically { "message" => "Successfully updated" }. Re-fetch with get_bucket if you need the updated Bucket struct.

Example — make a private bucket public

supabase.storage.update_bucket("avatars", public: true)

Example — tighten the MIME allowlist

supabase.storage.update_bucket(
  "avatars",
  allowed_mime_types: ["image/png", "image/jpeg", "image/webp"]
)

Example — raise the size cap

supabase.storage.update_bucket("private-uploads", file_size_limit: 50 * 1024 * 1024)

Example — change multiple fields at once

supabase.storage.update_bucket(
  "marketing-assets",
  public: true,
  file_size_limit: 25 * 1024 * 1024,
  allowed_mime_types: ["image/png", "image/jpeg", "image/svg+xml", "video/mp4"]
)

The wire payload always carries "name" => id even on update — storage-api ignores it when present alongside the unchanged id. This is intentional.

On this page