Box File URL format or how to get File URL from File ID
premise
- I have a file ID.
- I have right access permission to the file
I want to know a file URL from the file ID. I checked https://developer.box.com/reference/get-files-id/ , but it does not contain the file URL that accessed from users which has access permission.
I'm guessing file URL format is `https://app.box.com/file/#{file_id}`, but cannot find the documentation about this.
Anybody know that?
-
Hi Hiroyuki,
Please tell me a bit more about what are you trying to do.
If by file url you mean the download url, then you just need to add that fields to the query string.
For example for file id 1204688948039:
curl --location 'https://api.box.com/2.0/files/1204688948039?fields=id%2Ctype%2Cname%2Cdownload_url' \
--header 'x-rep-hints: [pdf]' \
--header 'Authorization: Bearer nVN...Z'I'm asking for id, type, name and download_url, and the response is:
{
"type": "file",
"id": "1204688948039",
"etag": "0",
"name": "Get Started with Box.pdf",
"download_url": "https://public.boxcloud.com/d/1/b1!djV6...ds./download"
}So by default the /files/file_id: end point returns a simplified version of the file object. If you need more information, you can specify the fields you're interested in. You can take a look at the full file object attributes here.
Now this download url is not a way to share the file, so it depends on your use case, meaning, what you want to do with this url.
Let us know if this helps.
-
Hi Rui,
Thank you for quick reply! It's very helpful!!
The file URL I meaned is simplest web access URL, which box users who has right access persmision can transit from https://app.box.com/folder/0, not mean download URL.
I just want to point to the location of the file, and leave what to do with it up to the user.
Thank you,
-
Hi Hiroyuki,
In that case it is as simple as https://app.box.com/file/1016197618492, where the number is the file identifier, like you mentioned.
I couldn't find the documentation about it either.
Best regards
-
Is it also possible for it to be of the form https://companyname.app.box.com/file/123 or it will also be https://app.box.com/file/123?
サインインしてコメントを残してください。
コメント
5件のコメント