How to download a file using API for Java
Hello,
We are using API to get the Akana token which we are using the get the Access token from Box( a 3 legged authorization).
Once we get the access token how can we use the token in java code to download the file?
BoxAPIConnection boxConnection = new BoxAPIConnection(accessToken);
boxConnection.getAccessToken();
String fileID = "11111";
BoxFile file = new BoxFile(boxConnection, fileID);
BoxFile.Info info = file.getInfo();
FileOutputStream stream;
try
{
stream = new FileOutputStream(info.getName());
file.download(stream);
stream.close();
} catch (FileNotFoundException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
When I pass the access token in constructor to create boxconnection e.g new BoxAPIConnection(accessToken);
it throws a client exception. I could not find any example which helps.
-
Have you reviewed the below?
- https://github.com/box/box-java-sdk/blob/master/doc/files.md#download-a-file
- https://github.com/box/box-java-sdk/blob/master/doc/authentication.md
If you're still having trouble after reviewing the above resources, please provide the following here or in a support ticket:
1.) Full body error response
2.) Date/time/timezone you received the error
3.) Client ID of your application
Best,
Kourtney
Box Technical Support Engineer
サインインしてコメントを残してください。
コメント
1件のコメント