Android - Get the URL of a file being downloaded

2019-06-02 15:03发布

问题:

I'm not sure if this is the right place to ask this question but I've looked around and couldn't find the answer.

An app that I'm building allows the user to download files, but I want to protect the URL of the files.

  • Is there a way to find the URL of a file being downloaded via an app?
  • If there is, can I prevent it somehow?
  • I am using download manager to download the files. Is it any different in this aspect if I write my own async methods?
  • Similarly, can users see the GET requests sent by the app?

Any info or direction to pages that talk more about this is appreciated.

Thanks.

回答1:

I am using download manager to download the files. Is it any different in this aspect if I write my own async methods?

If you are using DownloadManager to download files, depending on how you're using it, yes, users could get the URL quite easily, since the downloads app may show it. (this depends on how you're actually doing the download with DownloadManager, I'd need to see your code in order to tell you for sure.

If you write your own code to do the download, then yes, it will be harder for users to figure out where the file is being downloaded from.

Is there a way to find the URL of a file being downloaded via an app?

Even if you don't use DownloadManager, it is still possible, just more difficult. If users are using a firewall which logs network accesses, or something similar, your URLs will be logged and visible. Similarly, users can use a tool like Wireshark to see all networ traffic going between the device (and your app) and the server your data is coming from. On rooted devices, users can also install monitoring tools.

Similarly, can users see the GET requests sent by the app?

Yes, using the same tools (eg. wireshark), one can see exactly what URLs your app is requesting.

If there is, can I prevent it somehow?

No. If someone wants this information, they will get it, all you can do is make it harder. For starters though, I'd recommend not using DownloadManager and writing your own code instead, and using HTTPS. Additionally, you could try to ensure that your URL only works for users which have been authenticated in some way - check this question for possibilities.

Let me know if you have any other questions, and I'll try to help.