Skip to content

Deleting a File

To delete a file from the Backendless file storage, it must be identified by the file path/name. Files in the Backendless storage have the following URL structure:

https://api.backendless.com/<application id>/<REST API key>/files/<path>/<file name>

The API to delete a file uses the <path>/<filename> part to identify the file which must be deleted.

Non-Blocking API

public void Backendless.Files.remove( String filePath, AsyncCallback<Void> responder )

Blocking API

public void Backendless.Files.remove( String filePath ) throws Exception

where:

Argument                Description
filePath Path of the file to delete. The path must consist of the file path and file name.
responder A responder object which receives a callback when the method successfully deleted the file or if an error occurs. Applies to the asynchronous methods only.

Example

Backendless.Files.remove( "pictures/myphoto.png",
                           new AsyncCallback<Void>()
{
  @Override
  public void handleResponse()
  {
  }

  @Override
  public void handleFault( BackendlessFault backendlessFault )
  {

  }
}

Codeless Reference

files_api_delete_file_1

where:

Argument                Description
file path A path identifying a directory where a file must be deleted. The path must start with the root directory of the remote file storage.

This operation does not return a value.

Consider the following file stored in the notes directory:

files_api_delete_file_2

The example below deletes the "grocery.txt" file from the "notes" directory.

files_api_delete_file_3