I am currently trying out the code present in the docs of the file APIs. The file always seems to upload properly, but never returns the file URL. This is the code I’m using.
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>Files</title>
<script src="https://api.backendless.com/sdk/js/v4/beta/backendless.min.js"></script>
</head>
<body>
<input type="file" id="files" name="files[]" multiple />
<input type="button" onclick="uploadFileFunc(); return false;" value="Upload File"/>
<script>
Backendless.initApp( "XXXXXXXXXXXXXXXX", "XXXXXXXXXXXXX", "v1" );
document.getElementById('files').addEventListener('change', handleFileSelect, false);
function handleFileSelect(evt)
{
file = evt.target.files[0]; // FileList object
}
function uploadFileFunc()
{
var callback = {};
callback.success = function(result)
{
}
callback.fault = function(result)
{
alert( "error - " + result.message );
}
Backendless.Files.upload( file, "my-folder" )
.then( function( fileURLs ) {
console.log( "File successfully uploaded. Path to download: " + result.fileURL );
})
.catch( function( error ) {
console.log( "error - " + error.message );
})
};
</script>
</body>
</html>
Under “Backendless.Files.upload” the .then function does not return URLs. Is the code wrong?