File Upload Does Not Work with Appcelerator

I am using the following code snippet to upload a file to Backendless:

try {
      var fileURL = Backendless.Files.uploadSync( imageFile , 'images', true );
} catch( error ) {
      alert('Login error: ' + error.message + ' error code: ' + error.statusCode);

And I am getting an exception. Thinking that this was an Appcelerator issue, I tried to get assistance from them but they are pointing at Backendless as being the problem:
Apparently, the Backendless upload code is meant for websites and not mobile OS.

Hi Kam,

Is the “stream” node module included in the package of your app?


Hi Kam

We’ve added some fixes to UMD build, the latest version is 4.1.3.

Could you upgrade backendless.js lib to latest and try out if everything works fine

And also, I see that you are using “sync” method, it’s not good practice and in near future we will remove all the synchronous methods. You can use Promise

Regards, Vlad

Hi Vlad,

I used the new backendless.js 4.1.3 and am getting the following exception:

ERROR] : Script Error {
[ERROR] : column = 63247; 
[ERROR] : line = 1; 
[ERROR] : message = "undefined is not a function (evaluating 'Object.setPrototypeOf')"; 
[ERROR] : sourceURL = "file:///var/containers/Bundle/Application/E111F5B0-A270-484F-9FD6-2D0DF5C21934/"; 
[ERROR] : stack = "file:///var/containers/Bundle/Application/E111F5B0-A270-484F-9FD6-2D0DF5C21934/\nt@file:///var/containers/Bundle/Application/E111F5B0-A270-484F-9FD6-2D0DF5C21934/\nfile:///var/containers/Bundle/Application/E111F5B0-A270-484F-9FD6-2D0DF5C21934/\nt@file:///var/containers/Bundle/Application/E111F5B0-A270-484F-9FD6-2D0DF5C21934/\nfile:///var/containers/Bundle/Application/E111F5B0-A270-484F-9FD6-2D0DF5C21934/\nt@file:///var/containers/Bundle/Application/E111F5B0-A270-484F-9FD6-2D0DF5C21934/\nfile:///var/containers/Bundle/Application/E111F5B0-A270-484F-9FD6-2D0DF5C21934/\nt@file:///var/containers/Bundle/Application/E111F5B0-A270-484F-9FD6-2D0DF5C21934/\nfile:///var/containers/Bundle/Application/E111F5B0-A270-484F-9FD6-2D0DF5C21934/\nt@file:///var/containers/Bundle/Application/E111F5B0-A270-484F-9FD6-2D0DF5C21934/\nfile:///var/containers/Bundle/Application/E111F5B0-A270-484F-9FD6-2D0DF5C21934/\nt@file:///var/containers/Bundle/Application/E111F5B0-A270-484F-9FD6-2D0DF5C21934/\nfile:///var/containers/Bundle/Application/E111F5B0-A270-484F-9FD6-2D0DF5C21934/\nt@file:///var/containers/Bundle/Application/E111F5B0-A270-484F-9FD6-2D0DF5C21934/\nfile:///var/containers/Bundle/Application/E111F5B0-A270-484F-9FD6-2D0DF5C21934/\nt@file:///var/containers/Bundle/Application/E111F5B0-A270-484F-9FD6-2D0DF5C21934/\nfile:///var/containers/Bundle/Application/E111F5B0-A270-484F-9FD6-2D0DF5C21934/\nfile:///var/containers/Bundle/Application/E111F5B0-A270-484F-9FD6-2D0DF5C21934/\nt@file:///var/containers/Bundle/Application/E111F5B0-A270-484F-9FD6-2D0DF5C21934/\nfile:///var/containers/Bundle/Application/E111F5B0-A270-484F-9FD6-2D0DF5C21934/\nfile:///var/containers/Bundle/Application/E111F5B0-A270-484F-9FD6-2D0DF5C21934/\nfile:///var/containers/Bundle/Application/E111F5B0-A270-484F-9FD6-2D0DF5C21934/\nfile:///var/containers/Bundle/Application/E111F5B0-A270-484F-9FD6-2D0DF5C21934/\nglobal code@file:///var/containers/Bundle/Application/E111F5B0-A270-484F-9FD6-2D0DF5C21934/\nrequire@[native code]\nsuccess@file:///var/containers/Bundle/Application/E111F5B0-A270-484F-9FD6-2D0DF5C21934/"; 
[ERROR] : } 
[ERROR] : Script Error Module "libs/backendless.js" failed to leave a valid exports object 
[ERROR] : ErrorController is up. ABORTING showing of modal controller

this problem is fixed and new version 4.1.4 is released

let us know if you still have any problems with JS-SDK

Regards, Vlad

Hi Vald,

I try to run with the 4.1.4 but getting an error message returned from Backendless. Please see attached.



Could you please create a simple project, only with one button “upload file” for reproduce the problem, it really help up to resolve the problem
zip and send it to with link on this topic

Regards, Vlad

Hi Kam

I’ve received your email with the simple project and I’m working on it, I’ll let you you know about progress soon

Regards, Vlad

Hi Kam

We’ve created a patch for correct work JS-SDK with Titanium-SDK.

Could you please check this out, and confirm if everything works for you.

This patch does not include fix for “sync” file upload method, all “sync” methods will be removed in the nearest future.

I tested it for text file and also for image files from Titanium.Media.openPhotoGallery and all work.
I had iOS device for tests.


function uploadTextFile() {
 var textFile = Ti.Filesystem.getFile(Ti.Filesystem.tempDirectory, 'my-text-file.txt');
 textFile.write('The file is no longer empty!');

 Backendless.Files.upload(textFile, 'text-files', true)
 .then(function (result) {'fileURL: ' + result.fileURL);
 .catch(function (error) {
 Ti.API.error('File Upload error: ' + error.message);

function uploadImgFile() {
 success: function (event) {
 var imageFile = Ti.Filesystem.getFile(Ti.Filesystem.tempDirectory, 'my-image-file.png');

 imageFile.write(, 100));

 Backendless.Files.upload(imageFile, 'img-files', true)
 .then(function (fileURL) {'fileURL: ' + JSON.stringify(fileURL));
 .catch(function (error) {
 Ti.API.error('File Upload error: ' + error.message);

Regards, Vlad