1

I want to download the file from the URL such as -

mDownloadUrl = "https://onedrive.live.com/download?cid=xxx";

The problem is that i do not know the filename and content type. It can be pdf, doc, mp3 etc. If i use

DownloadManager.Request request = new DownloadManager.Request(Uri.parse(mDownloadUrl));

setDestinationInExternalPublicDir(dir, filename)

This requires that i know the filename along with the file extension. Also all third party services like onedrive does not support HEAD call (Give 404 error), so i can not get file name from Content-Disposition header.

Is there a way to just specify URL and Directory path and download the file by original name as in content disposition header?

Adheesh Bhatia
  • 41
  • 1
  • 1
  • 3
  • Does not support HEAD, or does not return Content-Disposition in the response? The former would be a severe bug that needs to be reported. – Julian Reschke Nov 18 '15 at 06:43
  • @JulianReschke I tried sending HEAD request to onedrive link using POSTMAN client. It did not respond. Do all servers support HEAD calls? I doubt that. At backend we can specify only allow POST or GET calls to a route. I think thats what onedrive has done. – Adheesh Bhatia Nov 18 '15 at 07:33
  • Edit: by did not respond i mean it gave 404. i am updating question – Adheesh Bhatia Nov 18 '15 at 07:45
  • So GET returns 200 and HEAD returns 404? Raise a bug report. – Julian Reschke Nov 19 '15 at 06:42

0 Answers0