Skip to main content

How to get direct link of my file using SDK?


I’m only getting the URL which is a direct download link and preview URL? how can I get the actual URL of the file? If its image file, I wanna get the URL with .jpg extension; not the preview or direct download ones

3 replies

pchristensen Box
  • Senior Staff Platform Solutions Engineer
  • 22 replies
  • June 19, 2024

Hi

Not sure if this would work or if you already looked at it but creating a shared link can provide a static link that does contain the file extension as part of the link. This is still a download link though but not sure what else you would be looking for ?

https://developer.box.com/reference/put-files-id--add-shared-link/ - looks something like this

 "shared_link": {
    "url": "https://app.box.com/s/kwio6b4ovt1264rnfbyqo1",
    "download_url": "https://app.box.com/shared/static/kwio6b4ovt1264rnfbyqo1.pdf",
  

Best regards
Peter Christensen, Platform Solutions Engineer, Box


  • Author
  • New Participant
  • 1 reply
  • June 19, 2024

Thank you for the response.

In API documentation it says to use
url = client.file(file_id).get_shared_link(access='open', allow_download=True, allow_edit=True)

But the new version of SDK don’t have file attribute.
It says ‘BoxClient’ object has no attribute ‘file’


pchristensen Box
  • Senior Staff Platform Solutions Engineer
  • 22 replies
  • June 19, 2024

Hi
I think you need to use client.files if you are using the new autogen SDK

Rgds
Peter


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings