My problem is that application that i created in Android and iOS cannot access the data fro Files. I mean, the application cannot download the images and videos that i have stored in Files at https://backendless.com/develop/#appKu/v1/main/files. I debugged my application and the log says
Authentication error: Unable to respond to any of these challenges: {}.
But access Data services, geolocation, user, and push notifications still worked normally.
Are backendless having a maintenances? Because my application tried download images and videos that i stored in Files at https://backendless.com/develop/#appKu/v1/main/files, the log always said
Authentication error: Unable to respond to any of these challenges: {}
I send the log in attachment files.
logauth.rar (261B)
Hi Aprido,
Could you please email your application ID to support@backendless.com? We will be glad to look into the problem.
Regards,
Mark
Thank you for your reply sir Mark Piller,
My application id is: #appKu.
Please look into it sir, because before i’m facing this issue, my device: Android and iOS can download images and videos in Files without any problems.
But now, the backendless server always rejecting my device request for downloading images and videos in FIles. But when i opened in browser, the images and videos can accessed… Weird.
Hi Aprido,
I suspect “appKu” is your application name. To find the application id, please login to Backendless Console, select your app, then click Manage. You will see the ID and secret keys in the App Settings section. I need the one from the Application ID field.
Regards,
Mark
Hello sir Mark Piller,
My apologies sir, this is my application id: 3711206D-C8C8-E352-FF9F-D7ACC2997300
And thank you.
Thank you! Also, would it be possible for you to share the Java/Android code with us which shows how you download a file from your Backendless backend?
Regards,
Mark
Hello sir Mark Piller,
This is Java/Android code for downloading the images and videos in Files:
public Bitmap loadImageFromServer(final String url) {
try
{
DefaultHttpClient httpclient = new DefaultHttpClient();
HttpRequestRetryHandler retryHandler = new HttpRequestRetryHandler() {
@Override
public boolean retryRequest(IOException exception, int executionCount,
HttpContext context) {
// TODO Auto-generated method stub
if (executionCount >= 5) {
// Do not retry if over max retry count
return false;
}
if (exception instanceof InterruptedIOException) {
// Timeout
return false;
}
if (exception instanceof UnknownHostException) {
// Unknown host
return false;
}
if (exception instanceof ConnectException) {
// Connection refused
return false;
}
if (exception instanceof SSLException) {
// SSL handshake exception
return false;
}
HttpRequest request = (HttpRequest) context.getAttribute(
ExecutionContext.HTTP_REQUEST);
boolean idempotent = !(request instanceof HttpEntityEnclosingRequest);
if (idempotent) {
// Retry if the request is considered idempotent
return true;
}
return false;
}
};
httpclient.setHttpRequestRetryHandler(retryHandler);
HttpGet httppost = new HttpGet(url);
//kirim request n ambil response
ResponseHandler<byte[]> responseHandler = new ResponseHandler<byte[]>() {
@Override
public byte[] handleResponse(HttpResponse response)
throws ClientProtocolException, IOException {
// TODO Auto-generated method stub
if (response.getEntity() != null)
{
return EntityUtils.toByteArray(response.getEntity());
}else{
response = new DefaultHttpClient().execute(new HttpGet(url));
return EntityUtils.toByteArray(response.getEntity());
}
}
};
byte[] bitmapData = httpclient.execute(httppost, responseHandler);
Log.d("message", String.valueOf(bitmapData.length)+" \n "+bitmapData.toString());
BitmapFactory.Options option = new BitmapFactory.Options();
option.inDither = true;
option.inPurgeable = true;
option.inInputShareable = true;
option.inScaled = true;
option.inDensity = 0;
option.inScreenDensity = 0;
option.inPreferredConfig = Config.RGB_565;
option.inTargetDensity = 0;
option.inTempStorage = new byte[2 * 1024];
b = BitmapFactory.decodeByteArray(bitmapData, 0, bitmapData.length);
httpclient.getConnectionManager().shutdown();
httppost.abort();
return b;
}catch (MalformedURLException e)
{
Log.d("error load", e.getMessage());
}catch (IOException e)
{
Log.d("error load", e.getMessage());
}
return b;
}
I load the images and videos using the link from each file in Files with class DefaultHttpConnection and getting the response from it. And then, i converting to Array of byte from response entity so from the Array of byte that i got, i could convert to bitmap so i can use the bitmap in my apps. But when i opened the link from each file in Files in browser, the browser could access and showing the images and videos in Files.
My apologies for my rough explanations sir.
Hello sir Mark Piller,
It looks like my mistake for placing the wrong link/url for downloading the images and videos. This is my mistake:
Tried to access the link : https://backendless.com/console/appversion/350402D1-6D7A-692E-FF27-D1DCFEF67500/files/download/images/3.jpg
But it should be like this : https://api.backendless.com/3711206d-c8c8-e352-ff9f-d7acc2997300/v1/files/images/3.jpg
My issues is clear now, for realizing the simple mistaken of placing the wrong link/url. And my apologies for troubling your, sir.
Hi Aprido,
This is correct. The URL which has /console/appversion is accessible to the app developer. When you are logged in to console, you (as a developer) can always open files. The other URL is the one visible to the application. Any file permissions you set would apply to that URL.
Regards,
Mark