cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to learn some quick and useful tips to make your day easier? Check out how Calvin uses Replay to get feedback from other teams at Dropbox here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Re: mulitple files upload doesnt work

mulitple files upload doesnt work

skaros
Helpful | Level 6

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.

4 Replies 4

Greg-DB
Dropbox Staff
You should certainly be getting some error or output. Have you stepped through it with a debugger to see what it's doing and what code path it's taking?

skaros
Helpful | Level 6

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

Greg-DB
Dropbox Staff
The UploadSessionFinishArg object is just an argument that you constructed. That is, it only is a way for you to specify parameter, but doesn't itself make the API call.

The actual API calls are to finish and check these are uploadSessionFinishBatch and uploadSessionFinishBatchCheck. What are those returning for you?

skaros
Helpful | Level 6

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)

Need more support?