Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Direct download link to OneDrive file?

A OneDrive sharable link looks like this: https://1drv.ms/w/s!AqmFiI7maXrRgT7PGcK_7JyZlBco. How do I get the direct download link version of this? I know with a onedrive.live/redir?<...> link I can just replace the 'redir' with 'download', but how do I do that for a link that looks like the one above? Thanks.

like image 837
ThePumpkinMaster Avatar asked Jun 21 '16 17:06

ThePumpkinMaster


People also ask

Can I download a file shared by OneDrive?

You can't download files directly from the Shared view. You will need to open the file and save a copy in the location of your choice.


2 Answers

If you follow the instruction here you can generate a URL that will act on the shared item, including being able to get its content.

In your case the URL would look like https://api.onedrive.com/v1.0/shares/u!aHR0cHM6Ly8xZHJ2Lm1zL3cvcyFBcW1GaUk3bWFYclJnVDdQR2NLXzdKeVpsQmNv/root/content

like image 194
Brad Avatar answered Sep 28 '22 08:09

Brad


You can also add a simple function to your .bashrc that will do the same trick:

onelink() { echo -n "$1"|base64|sed "s/=$//;s/\//\_/g;s/\+/\-/g;s/^/https:\/\/api\.onedrive\.com\/v1\.0\/shares\/u\!/;s/$/\/root\/content/"; }

Result is the same:

$ onelink 'https://1drv.ms/w/s!AqmFiI7maXrRgT7PGcK_7JyZlBco'
https://api.onedrive.com/v1.0/shares/u!aHR0cHM6Ly8xZHJ2Lm1zL3cvcyFBcW1GaUk3bWFYclJnVDdQR2NLXzdKeVpsQmNv/root/content
like image 33
Chris Avatar answered Sep 28 '22 07:09

Chris