Downloading publicly shared files from a different account: error 404

新規投稿

コメント

2件のコメント

  • 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
    コメントアクション パーマリンク
  • 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
    コメントアクション パーマリンク

サインインしてコメントを残してください。