Box Java SDK - Unable to download/delete specific versions of a file

521 views Asked by At

I am using the latest Box SDK for interacting with the Box API. I am able to successfully upload, download, delete and upload new version of a file.

However, I am unable to to delete one file version out of many, as suggested on the SDK page :

BoxDefaultRequestObject requestObj = new BoxDefaultRequestObject();
requestObject.getRequestExtras.setIfMatch(etag); //etag is file version starting from 0
boxClient.getFilesManager().deleteFile(fileId, requestObj);

This fails to delete the version and instead deletes the entire file.

Similarly, I am unable to download a specific file version either. Code for download :

BoxDefaultRequestObject downloadReq = new BoxDefaultRequestObject();
downloadReq.getRequestExtras().setIfMatch(versionId);
InputStream is = boxClient.getFilesManager().downloadFile(fileId, downloadReq);

This downloads the latest version only. Can anyone suggest how to make it work?

1

There are 1 answers

0
Raj Saxena On BEST ANSWER

After searching the source code of the open-source SDK, I realized that the capability didn't existed. I have made the necessary changes and submitted the pull request with them here

Code to delete version :

boxClient.getFilesManager().deleteFileVersion(fileId, boxVersion, requestObj);

Marking this as as answer as it is resolved.