Get file / image name from URL that does not end with file name and extension

My query is almost the same as the query listed in the following link:
How to get file name when clicking on url in web browser
I don’t know if you want to use URLUtil for the reasons indicated there.
Also, getting the file name using the Content-Disposition header does not work in my case.
I am using the Android API DownloadManager to upload a file / images. I have to set the destination file name using the setDestinationInExternalPublicDir method (String dirType, String subPath) .

I noticed that DownloadManager provides a name such as "downloadfile.jpeg", "downloadfile-2.jpeg" when the image URL is used. I looked at the DownloadManager source code and found COLUMN_LOCAL_FILENAME and COLUMN_TITLE that can store the file name.

How to get the file / image name, how is it done in the DownloadManager API?
If not, is there any way to find that these URLs do not contain the file name at the end so that I can specify my custom name?

+1
source share

All Articles