Welcome to the new Box Support website. Check out all the details here on what’s changed.

Tip: create a download link for a file

Completed
New post

Comments

3 comments

  • Official comment
    Alex Novotny

    Hey Nick, 

    Thanks for posting this tip. 

    Thanks, 

    Alex, Box Developer Advocate

    Comment actions Permalink
  • Oscar Felcan

    Hello all,

    I am currently attempting to take this 'download_url' and use it as a URL to pass to my own company API to then upload to our platform. But this isn't working. Making a request to that URL anonymously with curl is returning a 404 and pasting it into the browser shows that "This user is not allowed to use direct links. I guess this just confused me because I thought this would not be the case given access and can_download parameters. Thanks!

    0
    Comment actions Permalink
  • NICK CAWOOD

    I don't think that the download_url is cURL compliant. I have only ever used it in a browser.
    If you want to download a file that you've create a Share Link for I think you need to use the Box API again.

    Something like this (fileid is the fileid created when the file was uploaded and used in the API call of the share-link):

    curl -i -X GET "https://api.box.com/2.0/files/<fileid>/content" -H "Authorization: Bearer <BEARER-TOKEN>" -L --output <OUTPUT.New.Filename.pdf>

    Obviously the user who created the Bearer Token needs to have access to the File in Box.....so you might have to change the permissions on the File before they can download it. Or if it's the same user uploading, sharing and downloading the file then no changes to permissions are needed.

    Hope this helps.

    0
    Comment actions Permalink

Please sign in to leave a comment.