cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Are you interested in hearing how one of our Community members uses Dropbox for sailing trips? Read all about it 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: 

Can not upload large file by chunks

Can not upload large file by chunks

Nerses G.
New member | Level 2

I am trying to upload file by chunks. Here is my code 

self.client.files.uploadSessionStart(input: chunkOfData).response { response, error in

            if let result = response {

                // the call succeeded

                print(result)

 

                while(end < fileSize) {

                    end += self.CHUNK_SIZE;

                    var chunkOfData = data.subdataWithRange(NSRange(location: end, length: self.CHUNK_SIZE)) // get range of bytes from file

                    

                    self.client.files.uploadSessionAppendV2(cursor: Files.UploadSessionCursor(sessionId: result.sessionId, offset: end), input: chunkOfData)

                }

                

                // we're ready to finish the upload and commit the file

                self.client.files.uploadSessionFinish(cursor: Files.UploadSessionCursor(sessionId: result.sessionId, offset: end),

                    commit: Files.CommitInfo(path: self.filePath),

                    // no additional data to add at this point in this case

                    body:NSData()).response { response, error in

                        if let result = response {

                            print(result)

                        }

                        else {

                            print(error!)

                        }

                }

            } else {

                // the call failed

                print(error!)

            }

        }

Please help what am I doing wrong.

 

3 Replies 3

Greg-DB
Dropbox Staff

What specifically isn't working as expected? Are you getting an error?

There's a sample here that may be helpful:

https://stackoverflow.com/documentation/dropbox-api/409/uploading-a-file/1357/uploading-a-file-with-...

uosuser u.
New member | Level 1

Hi Gregory,

I too am unable to upload a file in chunks. As far as I remember this used to work earlier for sure. I am using v2 API. The error occurs at the /finish stage. The exact error is:

Error transferring https://content.dropboxapi.com/2/files/upload_session/finish - server replied: Bad Request

With HTTP status Code: 400

 The /start and /append_v2 sessions works and return Status Code: 200.

P.S: I'm using REST API v2.

Steve M.
Dropbox Staff

uosuser, please create a new thread to get help with your issue, and please share the body of the 400 response. (The body should be JSON that describes the error.)

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Steve M. Dropbox Staff
  • User avatar
    uosuser u. New member | Level 1
  • User avatar
    Greg-DB Dropbox Staff
What do Dropbox user levels mean?