Get the file/image name from the URL which does not end with a file name and extension

本小妞迷上赌 提交于 2019-12-08 03:17:12

问题


My query is almost similar to one asked in the following link :
How to get file name when clicking on URL in webview
I don't want to use URLUtil for the reasons mentioned there.
Also, getting the file name using Content-Disposition header field does not work in my case.
I am using Android DownloadManager API for downloading file/images. I have to set destination filename using setDestinationInExternalPublicDir (String dirType, String subPath) method.

I have observed that DownloadManager provide name such as "downloadfile.jpeg", "downloadfile-2.jpeg" when any image url is used. I have looked into the DownloadManager source code and found COLUMN_LOCAL_FILENAME and COLUMN_TITLE that might be storing the name of file.

How can I get the file/image name as done in DownloadManager API ?
If not, is there any way I can detect that these urls does not contain filename at the end so that I can provide my custom name ?

来源:https://stackoverflow.com/questions/24577166/get-the-file-image-name-from-the-url-which-does-not-end-with-a-file-name-and-ext

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!