Downloading a File with Javascript
How can I download a file from the Box API using client-side javascript? I've tried the following:
var url = 'https://api.box.com/2.0/files/file_id/content'; var xhr = new XMLHttpRequest(); xhr.open('GET', url); xhr.setRequestHeader('Authorization', 'Bearer '+my_token); xhr.onload = function() { //stuff } xhr.onerror = function() { //more stuff } xhr.send();
When the request is made, though, the following error is thrown:
XMLHttpRequest cannot load https://api.box.com/2.0/files//content. The request was redirected to 'https://dl.boxcloud.com/d/1/.../download', which is disallowed for cross-origin requests that require preflight.
サインインしてコメントを残してください。
コメント
1件のコメント