Downloading publicly shared files from a different account: error 404

New post

Comments

2 comments

  • cbetta

    Hi there.

     

    Any of our APIs support the boxapi header that allows you to specify the shared link that you want to use to access the file. Without this info, the API will return a 404 as you don't have access to the file explicitly.

    An example of this header is as follows:

    boxapi: shared_link=[link]&shared_link_password=[password]

    In Node, you can pass any headers to the options object.

    client.files.getReadStream('12345', { headers: { boxapi: "....." }}).then(...)
    0
    Comment actions Permalink
  • homekilo

    Thanks for your help.

    I was not able to make getReadStream work with BoxApi header in Node SDK ("headers" seem to be added as a GET param to the http request instead of being sent as actual headers).

    However, I was able to make it work via a custom GET request:

    const url = await client.get('https://api.box.com/2.0/files/' + file.id + '/content', {
        headers: {
          boxapi: 'shared_link=https://MY_LINK_HERE',
        },
    })

     

    — and then download file from url.headers.location

    0
    Comment actions Permalink

Please sign in to leave a comment.