[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 download a file and show the progress in a progressbar.
With my small image there is not much progress, it makes more sense to use this function with larger files.
B4X:
#If B4J
Private Sub xlbl_DownloadFile_MouseClicked (EventData As MouseEvent)
#Else
Private Sub xlbl_DownloadFile_Click
#End If
xui.SetDataFolder("supabase")
Wait For (xSupabase.Storage.DownloadFileProgress("Avatar","test.png",Me,"DownloadProfileImage",xui.DefaultFolder).Execute) Complete (StorageFile As SupabaseStorageFile)
If StorageFile.Error.Success Then
Log($"File ${"test.jpg"} successfully downloaded "$)
B4XImageView1.SetBitmap(xSupabase.Storage.BytesToImage(StorageFile.FileBody))
If File.Exists(xui.DefaultFolder,"test.png") Then File.Delete(xui.DefaultFolder,"test.png") 'Clean the download path, or do what ever you want
Else
Log("Error: " & StorageFile.Error.ErrorMessage)
End If
End Sub
Private Sub DownloadProfileImage_RangeDownloadTracker(Tracker As SupabaseRangeDownloadTracker)
If Tracker.CurrentLength > 0 Then
Log($"$1.2{Tracker.CurrentLength / 1024 / 1024}MB / $1.2{Tracker.TotalLength / 1024 / 1024}MB"$)
AnotherProgressBar1.Value = Tracker.CurrentLength / Tracker.TotalLength * 100
End If
End Sub