Upload File As Authenticated User - Javascript

I am trying to set up a folder where you can only upload/modify files if you are logged in. The problem is that when I deny access to Write & Remove for NotAuthorisedUser I can no longer upload the file even though I have logged in using the javascript API.
Calling " console.log(Backendless.UserService.getUserRoles()); " says that I am an Authenticated User but when I try to upload the file to the folder, it fails with an error saying I don’t have permission:
“Object {code: 4000, message: “User has no permissions to specified resource”}”
This is what i’ve done so far:
index.html:


<html>
 <head>
 <title>Test</title>
 <script src="libs/jquery.js"></script>
 <script src="libs/backendless.js"></script>
 </head>
 <body>


 <input id='fileUploadPicker' type='file' name="files[]" multiple />
 <script src="js/app.js"></script>
 
 </body>
</html>

js/app.js:


var APPLICATION_ID = /*AppID*/;
var SECRET_KEY = /*SecretKey*/;
var VERSION = 'v1';
 
var user;
var files;
if (!APPLICATION_ID || !SECRET_KEY || !VERSION)
 alert("Missing application ID and secret key arguments.");


init();
function init() {
 Backendless.initApp(APPLICATION_ID, SECRET_KEY, VERSION);
 
 try {
 user = Backendless.UserService.login("Admin", "abcd1234" );
 if (user != null)
 alert("Login successful");
 else
 alert("Login failed");
 }
 catch (e) {
 alert("Login failed. " + e.message);
 }
 
 $("#fileUploadPicker").change(function handleFileSelect(evt){
 
 files = evt.target.files; // FileList object
 uploadFile();
 
 });
 
}


function uploadFile(){
 
 function successCallback(file){ 
 console.log("Uploaded file URL - " + file.fileURL); 
 } 
 function errorCallback(e){ 
 console.log(e); 
 } 
 var async = new Backendless.Async(successCallback, errorCallback); 
 console.log(Backendless.UserService.getUserRoles());
 Backendless.Files.upload( files, "images", true, async );
}

And the attached file is a screenshot of how i’ve set up the folder permissions and also the console error that I get.
Am I doing something wrong? Am I missing something? Any help is much appreciated!

Hi Jake,

You discovered a bug - our code is not sending the “user-token” header along with the file upload API call. As a result, the permissions associated with the user are not triggered. We already have a fix, which is in QA right now.

Regards,
Mark

Hi Mark,

Do you have an ETA for the next Javascript API release that includes the fix?

Thanks,
Jake.

Hi Jake,

As soon as QA checks the fix, the code is then merged into the master branch in git. We will also post a message here to let you know.

Regards,
Mark

Thanks for the quick response, It Works!

Hi,

Is this still an issue? I think I’m having the same problem using the REST API. I have the same permissions configured in Data and Files and my Data requests work fine but uploading files I’m getting the following error: code: 4000, message: "User has no permissions to specified resources

Thanks,
Leroy