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.