Fail to restore file in trash
I run into a problem, I can't restore a file after trashing it. Code something like below. "com.box.sdk.BoxAPIException: The API returned an error code: 411" will be thrown when the method restoreFile is called.
BoxFolder folder = new BoxFolder(boxIntegrationService.getServerApiConnection(), myFolder);
FileInputStream f = new FileInputStream("\\Path To File\\file name");
BoxFile.Info tempFile = folder.uploadFile(f, timeStamp);
f.close();
tempFile.getResource().delete();
String id = tempFile.getID();
BoxTrash boxTrash = new BoxTrash(boxIntegrationService.getServerApiConnection());
boxTrash.restoreFile(id);
Then I try to add two optional parameters to restoreFile method, then the exception is gone,file is restored, but there is another issue,
no matter what newParentID is passed in method restoreFile, the file is restored with folder myFolder, where it's deleted.
newName an optional new name to give the file.
newParentID an optional new parent ID for the file.
Please sign in to leave a comment.
Comments
0 comments