Skip to content

Permissions API

Backendless security mechanism assigns an Access Control List (ACL) to every file in the file storage. An ACL defines users and user roles that have permissions to read, write, or delete a file. The Permissions API allows programmatic control over file ACL by granting or denying permissions to a file for a user or a user role. Using the API permissions can be applies for a user or user role individually or in "bulk" - for all users or user roles in a single call.

The path or the url argument in the APIs below must identify a file or directory for which the permission is modified. The value must be the short version of the path. For example, suppose the full URL of a file in the file storage system is:

https://backendlessappcontent.com/31CB9FED-F34C-5541-FF26-6C2B6719F200/23432-A6B2-FF6B-31CB9FED/files/movies/vacation.mp4

The path to the file in the API call must contain only the directory and the file name (without the leading slash):

movies/vacation.mp4

The user account (or the role) on which behalf the API is executed must contain the Permission permission. For example, if the call is made by an authenticated user, the role for the user account would be AuthenticatedUser. The role must have the Permission permission in order for the API call to go through.

To grant access for a user

Backendless.Files.Permissions.READ.grantUser( userid, url );
Backendless.Files.Permissions.DELETE.grantUser( userid, url );
Backendless.Files.Permissions.WRITE.grantUser( userid, url );

where:

Argument                Description
userid -ID of a user, for which you want to grant the read, delete, or write permission.
url -path to a file, for which you want to specify the permission.

To grant access for a user role

Backendless.Files.Permissions.READ.grantRole( rolename, url );
Backendless.Files.Permissions.DELETE.grantRole( rolename, url );
Backendless.Files.Permissions.WRITE.grantRole( rolename, url );

where:

Argument                Description
rolename -name of a user role, for which you want to grant the read, delete, or write permission.
url -path to a file, for which you want to specify the permission.

To grant access for all users

Backendless.Files.Permissions.READ.grant( url );
Backendless.Files.Permissions.DELETE.grant( url );
Backendless.Files.Permissions.WRITE.grant( url );

where:

Argument                Description
url path to a file, for which you want to specify the permission.

To deny access for a user

Backendless.Files.Permissions.READ.denyUser( userid, url );
Backendless.Files.Permissions.DELETE.denyUser( userid, url );
Backendless.Files.Permissions.UPDATE.denyUser( userid, url );

where:

Argument                Description
userid ID of a user for which you want to deny the read, delete, or write permission.
url path to a file, for which you want to specify the permission.

To deny access for a user role

Backendless.Files.Permissions.READ.denyRole( rolename, url );
Backendless.Files.Permissions.DELETE.denyRole( rolename, url );
Backendless.Files.Permissions.WRITE.denyRole( rolename, url );

where:

Argument                Description
rolename name of a user role, for which you want to deny the read, delete, or write permission.
url path to a file, for which you want to specify the permission.

To deny access for all users

Backendless.Files.Permissions.READ.deny( url );
Backendless.Files.Permissions.DELETE.deny( url );
Backendless.Files.Permissions.WRITE.deny( url );

where:

Argument                Description
url path to a file, for which you want to specify the permission.