Download photo URL without file name

Asked

Viewed 46 times

-1

I use to download files and photos the Glide or the Retrofit but had never come across the need I’m having now. The url is type http://meuserver.com/user/4564654/qrcode

the number is the user id and the qrcode is where the qrcode image file generated by the server is located, when I put this URL in the browser it downloads the normal image like any file being downloaded by the browser but inside Android I don’t know how to do it with Glide or Retrofit.

  • You want to download the image or show it in an Imageview for example?

  • Show it in Imageview!

1 answer

0

Glide and retrofit are libraries, in short, for different purposes. With the retrofit you will go to the server and fetch the image path or even download the file.

https://square.github.io/retrofit/

Using this library, you can bring the path where your image is, as stated in your question. When bringing the URL, use Glide to show it in your imageView.

@Override public void onCreate(Bundle savedInstanceState) {
  ...
  ImageView imageView = (ImageView) findViewById(R.id.my_image_view);

  GlideApp.with(this).load("http://suaurl").into(imageView);
}

https://github.com/bumptech/glide

  • Yes, true Glide is good for this but it does not download the URL file, it seems to me that it will only download if I enter the file name Ex.: 'http://suaurl.com/user/564564/qrcode/user_564564_qrcode.png' but not if the address is: 'http://suaurl.com/user/564564/qrcode'

  • The address must be complete, of the file, this address it generates what? A list of images? You can download the file, save to a local folder and open the path in imageView or Glide or Picasso

  • It generates an archive, only a file inside that folder, the final URL. When I copy and paste the URL into Chrome it simply downloads the file, but in Glide it from the error, it does not download.

  • Then you will have to load after downloading the file.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.