Search code examples
iosbox-apibox

Get file download link using BOX SDK iOS


I'm using BOX SDK in my app. I need to get the file download link, so that i can send that link to server and download there. How can i get file download link.


Solution

  • As shared_link object has the direct download_link but this doesn't allow you to download file directly, instead it requires a explicit click.

    I've done a workaround which leads to the successfull download of Box file directly. Moreover i've a basic Box Account.

    Two things you'll need to get.

    • File ID - Its explicitly given in Box file object as id.
    • Shared ID - Not explicitly given in box file's shared_link object, but can be extracted from url e.g. https://app.box.com/s/[YOUR_SHARED_ID].

    Now We can construct download manually.

    https://app.box.com/index.php?rm=box_download_shared_file&shared_name=[FILE_SHARED_ID]&file_id=f_[FILE_ID]
    

    I Know this is a bit hacky but this does solves our problem correctly. Note that this direct access url hack will stop working if they change the format of the url at box's server side ...