Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
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.
I am not getting any error at all. Everything seems to be working as it should.
I print out the
UploadSessionFinishArg.toStringMultiline() and got this
{
"cursor" : {
"session_id" : "AAAAAAADdQAca70DFR87FA",
"offset" : 160622
},
"commit" : {
"path" : "/khmdhsData/testing/builderTest/aw.tmp",
"mode" : "overwrite",
"autorename" : false,
"client_modified" : "2017-03-02T08:15:39Z",
"mute" : false
}
}
So it seems to be working. But nothing is uploaded! How can i check the state of the uploading. have no idea how to debug this
It seemed that the problem was on this line
sessionId = client.files().uploadSessionStart(false).uploadAndFinish(in).getSessionId();
from the
public MultipleUpload addFile()
changed it to this
sessionId = client.files().uploadSessionStart(true).uploadAndFinish(in).getSessionId();
and it seems to be working (so far at least)
Hi there!
If you need more help you can view your support options (expected response time for a ticket is 24 hours), or contact us on X or Facebook.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!