Aelliott1485 Aelliott1485 - 2 months ago 24
Javascript Question

How can I get share and download links from OneDrive API

I am using the OneDrive JS Picker and would like to get both a download and share value. The sample in the documentation lists the options for the action parameter separated by pipes. I was hoping to use bitwise operators to combine those values (e.g.

action: "share | download"


but that doesn't seem to allow both the webUrl value and the download url (@microsoft.graph.downloadUrl)... has anybody else been able to do this? Or is there a way to use the share URL (webUrl) to get a download url so we can get the text contents of files?

I know there is a REST service available though that may be deprecated, given the message at the top of that page:


This documentation is archived and is not being maintained.


but if that is still usable, perhaps we could use that to download the file... if so, can I put the file id in that download URL and an access token?

Answer

I was able to host the OneDrive.js file locally, un-minify it and modify the line below (line 104) to have the downloadUrl included in all queries on files. That allows us to get a shareUrl and a downloadUrl.

e.DEFAULT_QUERY_ITEM_PARAMETER = "expand=thumbnails&select=id,name,size,webUrl,folder,@content.downloadUrl";