0

Currently, I am building a javascript app that provides OneDrive filesystem support for chromeOS. Unfortunately, I encounter an issue when downloading a file via the OneDrive API due to preflights failing.

Deeply buried in the Microsoft API docs there is a mention of a workaround for CORS request for javascript apps, because preflights will fail. In order to circumvent a 302 redirect, a file download has to be executed in two steps: first get the download url, then download the file via that url. This works fine as a simple GET request doesn't require a preflight check.

Back to the filesystem. According to the chrome.fileSystemProvider API docs:

The results must be returned in chunks by calling successCallback several times.

This can be achieved by using the Range header on the GET request to the download-url, which actually is supported by OneDrive API using partial range downloads. However, now the request isn't simple anymore and therefore requires a preflight check, which ultimately fails.

So basically, the workaround failed because the problem the workaround tried to work around is still present in the workaround.

How can I overcome this problem? I obviously don't want to funnel the request through a proxy because of bandwidth and privacy issues. Can I perhaps simulate the Range header by downloading the entire file first and then serving it in byte-size chunks to the fileSystemProvider? I came across a question asked almost 5 years ago with a very similar issue, but unfortunately it didn't get me any further.

Darrel Miller
  • 139,164
  • 32
  • 194
  • 243
Steve
  • 65
  • 5
  • Can you confirm what OneDrive endpoint you're hitting (Business or Personal)? – Brad Sep 22 '19 at 21:26
  • I write for OneDrive for business, so the downloadUrl I retrieve from the api points to a file on a sharepoint source (still on office365 though). – Steve Sep 23 '19 at 14:49
  • It does seem like there isn't a valid work around for this scenario - we'll need to make sure `download.aspx` supports `OPTIONS` in order to get the scenario working. – Brad Sep 26 '19 at 22:24

0 Answers0