LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Programatically Download File from Public OneDrive Link

Solved!
Go to solution

Hello all,

I am trying to figure out how to programmatically download a file from a public OneDrive link. (For reference, this is my OneDrive)

 

My aim is to:

  • Download ZIP from public link (static) and save it locally.

I am willing to use .NET, ActiveX, HTTP, Datasocket, but I cannot get any of them to work with the URLs below.

 

This is the link that OneDrive tells me to share with others:

</Link Removed/>

 

A bit of digging provides this "direct" link to the ZIP:

</Link Removed/>

 

or

 

</Link Removed/>

 

I cannot get the HTTP Get to return the zip file, I can navigate to the links with the .NET WebBrowser Control but it prompts the user where to download, rather than programmatic control.

 

Any suggestions on how to accomplish this?

0 Kudos
Message 1 of 2
(148 Views)
Solution
Accepted by topic author Gryffin

I have figured it out!

 

  1. To accomplish this task, you will need to setup a "Public" OneDrive folder (Anyone with link can view).
  2. Then, host your desired .ZIP file in the "Public" folder.
  3. In OneDrive online, create a link to the .ZIP with permissions: Anyone with link can view.
  4. Now, in an Incognito Window, navigate to your URL for the .ZIP.
  5. Open "Inspect Element", then monitor the network traffic while you click on "Download" on the page.
  6. You now have a direct link to your OneDrive file!
  7. In order to download it into LabVIEW, open an HTTP handle, make a first GET request to OneDrive's recommended sharing link, then a second GET request to the direct URL you found earlier. The body of the second GET request is your file in binary form.
  8. To convert it into a ZIP, use "Write Binary File", wire the body string directly into the write (after having opened/created a binary file), and viola, you now have downloaded a ZIP from a public OneDrive link in LabVIEW!
0 Kudos
Message 2 of 2
(123 Views)