Downloading files Java API
Hi,
We are trying to read files using BOX API. Users to my application will just send the file URL and we need to download the file and process.
My application is written Java ( Spring Boot).
User can send file URL from their own accounts also.
From the docs, i got the below code. But I have couple of basic questions.
How to get authenticated to Box and what is the "id" in the constructor for BoxFile?
BoxFile file = new BoxFile(api, "id");
BoxFile.Info info = file.getInfo();
FileOutputStream stream = new FileOutputStream(info.getName());
file.download(stream);
stream.close();
Can you please help here?
Thanks
SD
-
Hi ,
To get authenticated with Box, you can use this guide to set up a JWT application, and this guide will walk you through the auth process.
That id param is the Box file ID. You can get a file ID in a few different ways:
- Through the APIs, generally you will get file information when you upload a file via (return JSON includes the file ID), or if you are searching for particular files to download using the search endpoint, or if you are retrieving a list of files in a given folder.
- If you load up the file visually in box.com, the URL should look something like https://cloud.app.box.com/file/33456445430. The last series of numbers in the URL for a file or folder will always be the ID of that file or folder.
Hope that helps,
Jon
サインインしてコメントを残してください。
コメント
3件のコメント