[B4X] PocketBase - Open Source backend in 1 file
PocketBase was created to assist building self-contained applications that can run on a single server without requiring to install anything in addition. The basic idea is that the common functionality like crud, auth, files upload, auto TLS, etc. are handled out of the box, allowing you to focus...

Please read the official documentation about deleting files in pocketbase:
PocketBase - Open Source backend in 1 file
Open Source backend in 1 file with realtime database, authentication, file storage and admin dashboard

There are several ways to delete files with the B4X-Pocketbase SDK.
Delete Specific Files from a Record (DeleteFiles)
Deletes a specific file or multiple files from a record.
B4X:
Wait For (xPocketbase.Storage.DeleteFiles("dt_Task","77avq8zn44ck37m","Task_Image",Array As String("test_l586xluw7q.jpg"))) Complete (DatabaseResult As PocketbaseDatabaseResult)
xPocketbase.Database.PrintTable(DatabaseResult)
CollectionName
: The name of the collection where the record exists.RecordID
: The ID of the record that contains the file.ColumnName
: The name of the field where the file is stored.DocumentNames
: An array of file names to be deleted.
With this function you can delete several file columns at once.
B4X:
Dim UpdateRecord As Pocketbase_DatabaseUpdate = xPocketbase.Database.UpdateData.Collection("dt_Task")
UpdateRecord.Update(CreateMap("Task_Image-":"test_6byr5kmo3b.jpg")) 'If you want to delete individual file(s) from a multiple file upload field, you could suffix the field name with - and specify the filename(s) you want to delete
Wait For (UpdateRecord.Execute("8u7928b58636n76")) Complete (DatabaseResult As PocketbaseDatabaseResult)
xPocketbase.Database.PrintTable(DatabaseResult)
CollectionName
: The name of the collection.FieldName
: The field that contains the file.FileName
: The specific file to be deleted.RecordID
: The ID of the record.
- This method removes specific files from a multi-file upload field.
- The
-
suffix is used to specify which file(s) should be deleted.
Removes all files from a file field in a record.
B4X:
Dim UpdateRecord As Pocketbase_DatabaseUpdate = xPocketbase.Database.UpdateData.Collection("dt_Task")
UpdateRecord.Update(CreateMap("Task_Image":""))
Wait For (UpdateRecord.Execute("8u7928b58636n76")) Complete (DatabaseResult As PocketbaseDatabaseResult)
xPocketbase.Database.PrintTable(DatabaseResult)
CollectionName
: The name of the collection.FieldName
: The field that contains the file.RecordID
: The ID of the record.
- This method deletes all files associated with a specific field by setting its value to an empty string ("").
Conclusion
With these three methods, you can manage file deletions in PocketBase efficiently:- DeleteFiles → Remove specific files using Storage.DeleteFiles().
- Delete Individual Files from Multi-File Fields → Use the - suffix in UpdateData.Update().
- Delete All Files → Set the field value to an empty string.