Your workflow is unique 👨‍💻 -  tell us how you use Dropbox here.

Forum Discussion

Nerses G.'s avatar
Nerses G.
New member | Level 2
9 years ago

Can not upload large file by chunks

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

About Dropbox API Support and Feedback

Node avatar for Dropbox API Support and Feedback
Get help with the Dropbox API from fellow developers and experts.

The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.

If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X, Facebook or Instagram.

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!