File permission NotAuthenticatedUser

Hi! I would like to grant READ permission for “NotAuthenticatedUser” after creating file, but i’m not able.
My code:

BackendlessFile mediaFile = ...
FilePermission.READ.grantForRole("NotAuthenticatedUser", mediaFile.getFileUrl());

I have no exception but in console the file hasn’t read permission (for NotAuthenticatedUser role)

Hello @kegita,
Are you able to alter role permissions using Concole?
Artur

Yes, i’m able. The problem is only the code, that it seems to have no effect. (i am AuthenticatedUser when i create the file and the AuthenticatedUser has granted all permissions by default on file)

I assume there is a logged in user at the time when the “grantForRole” method is called. Does the “AuthenticatedUser” role or the specific logged in user have the “Permission” permission?

Mark

How can i check it ad runtime???

however, from dashboard
http://support.backendless.com/public/attachments/55560654b675ceecd0c0a30a53695ac4.jpg</img>

55560654b675ceecd0c0a30a53695ac4.jpg

You can check it using console:

    Upload a file using API Open console and navigate to the file Click the "lock" icon for the file Switch to "Roles Permissions" See the "Permission" column and the row for the role in question.

Yes, the AuthenticatedUser has “Permission” permission

Thank you. I just tried the same thing and notices that the “url” parameter must be of a specific format.

For example, the call to mediaFile.getFileUrl() may return this:

https://api.backendless.com/31CB9FED-F34C-5541-FF26-6C2B6719F200/v1/files/movies/vacation.mp4

The “url” argument for that file for this call:

FilePermission.READ.grantForRole("NotAuthenticatedUser", url);

must be this:

"movies/vacation.mp4"

In that case, it works as expected.

I will make sure the doc is updated to reflect this.

Mark

Thank you! now it works!