Reputation: 514
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.
Upvotes: 1
Views: 1292
Reputation: 514
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.
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 ...
Upvotes: 2
Reputation: 2599
The information you are looking for is in the "shared_link" section of the file JSON. It looks like this:
"shared_link": {
"url": "https://www.box.com/s/rh935iit6ewrmw0unyul",
"download_url": "https://www.box.com/shared/static/rh935iit6ewrmw0unyul.jpeg",
"vanity_url": null,
"is_password_enabled": false,
"unshared_at": null,
"download_count": 0,
"preview_count": 0,
"access": "open",
"permissions": {
"can_download": true,
"can_preview": true
}
Box APIs in general are symmetric in their inputs and outputs, so if you do not already have a download_url on a particular file you are looking at, and want to get one, you should set the "shared_link"-> "permissions" -> "can_download" to true, and Box will generate a downloadable shared-link for your file.
Upvotes: 1