[B4X] Supabase - The Open Source Firebase alternative
Supabase is an open source Firebase alternative. It provides all the backend services you need to build a product. Supabase uses Postgres database with real-time capabilities. Basically, supabase provides an interface to manage postgres database that you can use to create table and insert, edit...
www.b4x.com
This is a very simple tutorial on how to use the storage bucket options.
CREATE
Creates a new Storage bucket
Name - A unique identifier for the bucket you are creating
B4X:
Dim CreateBucket As Supabase_StorageBucket = xSupabase.Storage.CreateBucket("Avatar")
CreateBucket.Options_isPublic(False)
CreateBucket.Options_FileSizeLimit(1048576 )
CreateBucket.Options_AllowedMimeTypes(Array("image/png","image/jpg"))
Wait For (CreateBucket.Execute) Complete (Bucket As SupabaseStorageBucket)
If Bucket.Error.Success Then
Log($"Bucket ${Bucket.Name} successfully created "$)
Else
Log("Error: " & Bucket.Error.ErrorMessage)
End If
Retrieves the details of an existing Storage bucket.
B4X:
Dim GetBucket As Supabase_StorageBucket = xSupabase.Storage.GetBucket("Avatar")
Wait For (GetBucket.Execute) Complete (Bucket As SupabaseStorageBucket)
If Bucket.Error.Success Then
Log($"Bucket ${Bucket.Name} was created at ${DateUtils.TicksToString(Bucket.CreatedAt)}"$)
Else
Log("Error: " & Bucket.Error.ErrorMessage)
End If
Updates a new Storage bucket
B4X:
Dim UpdateBucket As Supabase_StorageBucket = xSupabase.Storage.UpdateBucket("Avatar")
UpdateBucket.Options_isPublic(True)
UpdateBucket.Options_FileSizeLimit(1048576 )
UpdateBucket.Options_AllowedMimeTypes(Array("image/png"))
Wait For (UpdateBucket.Execute) Complete (Bucket As SupabaseStorageBucket)
If Bucket.Error.Success Then
Log($"Bucket ${Bucket.Name} successfully updated "$)
Else
Log("Error: " & Bucket.Error.ErrorMessage)
End If
Deletes an existing bucket. A bucket can't be deleted with existing objects inside it. You must first empty() the bucket.
B4X:
Dim DelteBucket As Supabase_StorageBucket = xSupabase.Storage.DeleteBucket("Avatar")
Wait For (DelteBucket.Execute) Complete (Bucket As SupabaseStorageBucket)
If Bucket.Error.Success Then
Log($"Bucket ${Bucket.Name} successfully deleted "$)
Else
Log("Error: " & Bucket.Error.ErrorMessage)
End If
Removes all objects inside a single bucket.
B4X:
Wait For (xSupabase.Storage.EmptyBucket("Avatar").Execute) Complete (Bucket As SupabaseStorageBucket)
If Bucket.Error.Success Then
Log($"Bucket ${Bucket.Name} successfully cleared "$)
Else
Log("Error: " & Bucket.Error.ErrorMessage)
End If