4

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?

Raj Saxena
  • 852
  • 10
  • 18
  • I was able to make download of a specific version work as follows : `requestObj.getRequestExtras().addQueryParam("version", boxVersion);` Here, `boxVersion` is the id of the BoxFileVersion object that I get from the list of versions by calling `boxClient.getFilesManager().getFileVersions(fileId, null);` Still, need help on deleting a specific version. – Raj Saxena Nov 12 '14 at 15:20

1 Answers1

3

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.

Raj Saxena
  • 852
  • 10
  • 18