I am unable to download the image. I use the link https://develop.backendless.com/console/app id/appversion/5ABCC519-94A5-2CCB-FFBA-11F90089D100/tpkdvultxigveqytmbhkmbcdgawqhhsfhldg/files/view/path of image/(name of image)%3Foverwrite%3Dfalse
to download the image.
It works well for a small period of time. But this is also temporary. After some time the portion after appversion keeps on changing automatically. I guess this may be due to backendless.
Please someone suggest how to download an image stored in files in backendless to an android application.
Thank you
Here is the code
public class image extends AppCompatActivity {
private Bitmap bitmap;
private ImageView iv;
public static String link1; @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.image);
String appVersion = “v1”;
Backendless.initApp(this, “A0EC8CE8-BC06-EC54-FFE2-9B50776AAA00”, “AE1E553B-0836-C1E1-FFAF-96E976956000”, “v1”);
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(policy);
iv =(ImageView)findViewById(R.id.image1);
bitmap=loadImageFromServer("https://api.backendless.com/A0EC8CE8-BC06-EC54-FFE2-9B50776AAA00/v1/files/img/IMG_20150423_100810.jpg");
TextView msg=(TextView)findViewById(R.id.msg);
msg.setText(link1);
iv.setImageBitmap(bitmap);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
public Bitmap loadImageFromServer( final String src){
try{
URL url= new URL(src);
HttpURLConnection connection= (HttpURLConnection)url.openConnection();
connection.setDoInput(true);
connection.connect();
InputStream input=connection.getInputStream();
Bitmap myBitmap= BitmapFactory.decodeStream(input);
return myBitmap;
}catch (Exception e)
{
e.printStackTrace();
return null;
}
} @Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
You are unable to download files using console routes, you should use public routes for files. The public route you can get in console via Files > Actions > Get public URL (icon).