Class: Supabase::Storage::Client
- Defined in:
- lib/supabase/storage/client.rb
Overview
Sync Storage client. Constructed once per project; reused across requests.
client = Supabase::Storage::Client.new(
base_url: "https://project.supabase.co/storage/v1",
headers: { "apikey" => key, "Authorization" => "Bearer #{token}" }
)
client.list_buckets # bucket-management surface
client.from("avatars").upload(...) # file-level surface, scoped to one bucket
Direct Known Subclasses
Instance Attribute Summary collapse
-
#base_url ⇒ Object
readonly
Returns the value of attribute base_url.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
Instance Method Summary collapse
-
#analytics ⇒ Object
Iceberg / analytics bucket management.
-
#from(bucket_id) ⇒ Object
(also: #bucket)
Return a FileApi scoped to the given bucket.
-
#initialize(base_url:, headers: {}, http_client: nil, verify: true, proxy: nil, timeout: nil) ⇒ Client
constructor
A new instance of Client.
-
#vectors ⇒ Object
Vector bucket / index / record management.
Methods inherited from BucketApi
#create_bucket, #delete_bucket, #empty_bucket, #get_bucket, #list_buckets, #update_bucket
Constructor Details
#initialize(base_url:, headers: {}, http_client: nil, verify: true, proxy: nil, timeout: nil) ⇒ Client
Returns a new instance of Client.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/supabase/storage/client.rb', line 32 def initialize(base_url:, headers: {}, http_client: nil, verify: true, proxy: nil, timeout: nil) @verify = verify @proxy = proxy @timeout = timeout @http_client = http_client normalized = base_url.to_s normalized = "#{normalized}/" unless normalized.end_with?("/") default_headers = { "X-Client-Info" => "supabase-rb/storage-rb v#{VERSION}" }.merge(headers) super(http_client || build_session(normalized), normalized, default_headers) end |
Instance Attribute Details
#base_url ⇒ Object (readonly)
Returns the value of attribute base_url.
24 25 26 |
# File 'lib/supabase/storage/client.rb', line 24 def base_url @base_url end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
24 25 26 |
# File 'lib/supabase/storage/client.rb', line 24 def headers @headers end |
Instance Method Details
#analytics ⇒ Object
Iceberg / analytics bucket management. Mirrors storage3’s ‘SyncStorageClient#analytics`.
56 57 58 |
# File 'lib/supabase/storage/client.rb', line 56 def analytics @analytics ||= AnalyticsClient.new(@session, @base_url, @headers) end |
#from(bucket_id) ⇒ Object Also known as: bucket
Return a FileApi scoped to the given bucket.
48 49 50 |
# File 'lib/supabase/storage/client.rb', line 48 def from(bucket_id) FileApi.new(bucket_id, @base_url, @headers, @session) end |
#vectors ⇒ Object
Vector bucket / index / record management. Mirrors storage3’s ‘SyncStorageClient#vectors`.
62 63 64 |
# File 'lib/supabase/storage/client.rb', line 62 def vectors @vectors ||= VectorsClient.new(@session, @base_url, @headers) end |