How to download files from OneDrive

ARH picture ARH · Jul 3, 2014 · Viewed 22.1k times · Source

I am looking to download my files in public folder from One Drive, but it doesn't download the files. Here is the scenario:

In public folder I have another folder with multiple files in it and is accessible widely. for test purpose I have shared all the files in public folder (I don't if it's proper way of sharing it).

The following links are provided for me to download the file:

  1. From shared folder link https://onedrive.live.com/redir?resid=DBBC281099F4FE69!646&authkey=!AGRCGuw8Y2_p9mA&ithint=folder%2c.mp3
  2. From public folder link https://onedrive.live.com/redir?resid=DBBC281099F4FE69%21646
  3. Direct link http://1drv.ms/1z9XlW6 -

I am using BackgroundTransferRequest to download the file using below code:

string filePathToDownload = string.Empty, fileName = "111.mp3";
filePathToDownload = "http://1drv.ms/1z9XlW6";

Uri transferUri = new Uri(Uri.EscapeUriString(filePathToDownload), UriKind.RelativeOrAbsolute);
BackgroundTransferRequest transferRequest = new BackgroundTransferRequest(transferUri);
transferRequest.Method = "GET";
transferRequest.TransferPreferences = TransferPreferences.AllowCellularAndBattery;

Uri downloadUri = new Uri(DataSource.TEMPDOWNLOADLOCATION + fileName, UriKind.RelativeOrAbsolute);
transferRequest.DownloadLocation = downloadUri;
transferRequest.Tag = fileName;

The file is 300Kb, but this only downloads 6 Kb.

How can I directly download the file from the links above (any of them)?

thanks!

Answer

Michael picture Michael · May 3, 2015

If you replace the word redir with download in the url you get the raw file instead of the webpage i.e.

https://onedrive.live.com/download?resid=DBBC281099F4FE69%21646