supabase-rb-rb
Storage

Delete files in a bucket

Delete one or more objects from a bucket.

Delete the given paths from the bucket. Accepts either a single String path or an Array<String> of paths — single paths are wrapped automatically via Array(paths).

Signature

supabase.storage.from(bucket_id).remove(paths)

Parameters

NameTypeRequiredDescription
pathsString, Array<String>RequiredOne or more object paths inside the bucket. A bare String is auto-wrapped into a single-element array. Sent as { "prefixes" => [...] }.

Returns

Returns
Array<Hash>

The list of object records that were deleted (each entry carries "name", "id", "bucket_id", "metadata", timestamps). Paths that didn't exist are silently omitted — the response is the intersection of paths and the bucket's actual contents.

Example — delete a single object

supabase.storage.from("avatars").remove("people/ada.png")

Example — bulk delete

supabase.storage.from("invoices").remove(
  ["2025/Q4/INV-0042.pdf", "2025/Q4/INV-0043.pdf", "2025/Q4/INV-0044.pdf"]
)

Example — clear an entire prefix

prefix = "drafts/"
paths  = supabase.storage.from("blog").list(prefix).map { |row| "#{prefix}#{row['name']}" }
supabase.storage.from("blog").remove(paths) unless paths.empty?

Sends DELETE /object/<bucket> with { "prefixes": [...] }. Array(paths) wrapping means a bare String is accepted alongside an array.

On this page