I am using the java sdk to upload files on dropbox. Since i want to upload a bunch of them, i tried the chunck upload method. This is what i got.
public MultipleUpload addFile(File file,String path) throws DbxApiException, DbxException, IOException {
in = new FileInputStream(file);
sessionId = client.files().uploadSessionStart(false).uploadAndFinish(in).getSessionId();
offset = file.length();
cursor = new UploadSessionCursor(sessionId, offset);
int index =file.getAbsolutePath().indexOf(path);
commitInfo = new CommitInfo(path, WriteMode.OVERWRITE, false, new Date(), false);
UploadSessionFinishArg arg = new UploadSessionFinishArg(cursor, commitInfo);
entries.add(arg);
return this;
}
public void commit() throws DbxException, InterruptedException {
int count=0;
LaunchEmptyResult result = client.files().uploadSessionFinishBatch(entries);
while (count<10){
try { if(!client.files().uploadSessionFinishBatchCheck(result.getAsyncJobIdValue()).isInProgress()) {
//all ok
System.out.println("(((END"+new Date());
return;
}
System.out.println("Try Again");
Thread.sleep(5000);
} catch (DbxException e){
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
and in order to use it i call
addFile(new File("localfile.xxx"), "/testing/builderTest/bw.tmp")
.addFile(new File("localfile.xxx"), "/testing/builderTest/aw.tmp")
.commit();But this is not uploading anything, and it doesnt return any error either.
any help is highly appreciated.