Forum Discussion

mickedg's avatar
mickedg
Helpful | Level 6
9 years ago

swifty dropbox route error incorrect offset

Hi - I'm using Swifty Dropbox to upload individual files to another dropbox using 

let dbClient = DropboxClient(accessToken: "xxxxx....."

and the methods

func doUpload(fileName: String)
func uploadFirstChunk()
func uploadNextChunk()

In this part:

dbClient.files.uploadSessionAppendV2(cursor: Files.UploadSessionCursor(sessionId: self.sessionId, offset: UInt64(offset)), input: data!)
                .response { response, error in
                    if error == nil {
                        self.offset += self.chunkSize
                        self.uploadProgress = Double(self.offset)/Double(self.videoFileSize)
                        self.progressView.progress = Float(self.uploadProgress)
                        self.uploadNextChunk()
                        
                    } else if let callError = error {


I' ve seen Route Error/IncorrectOffset: {"correct_offset" = 1048576;}. 

A beta tester has also reported it. It's not consistent, I only get it occasionally.

What does it mean?

 

4 Replies

  • mickedg's avatar
    mickedg
    Helpful | Level 6
    9 years ago

    I found this explanation for the Incorrect Offset error: "The specified offset was incorrect. See the value for the correct offset. This error may occur when a previous request was received and processed successfully but the client did not receive the response, e.g. due to a network error."

    Is there anything I can do if this error is very frquent?

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    9 years ago
    That's the correct documentation for this error. It generally shouldn't happen often, but if it does, it may indicate an issue with your upload session logic that you should debug.

    When you do get it though, you can have your app continue with the upload session, but pick it up from the specified correct offset. For example, in this case the API indicated that it received data up to offset 1048576 so far, so your app should continue the upload session by uploading further portions of data starting at offset 1048576.
  • mickedg's avatar
    mickedg
    Helpful | Level 6
    9 years ago

    Thanks Greg! I've lowered the chunk size to 1 MB, could that be the problem? I wanted to do that in order to get a smoother progress view. The files that I'm uploading are typically around 100 - 200 MB. What would be the optimal chunk size from a performance perspective?

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    9 years ago
    You can use whatever chunk size you want, and the chunk size itself shouldn't cause an incorrect offset error.

    There isn't an optimal chunk size in general, as there are various different factors, often app-specific, or even user-specific, that will come in to play to affect this. That being the case, you may want to try a few different ones to see what works best for your app. In general though, the larger the chunk size, the better the performance, as there's less overhead associated with making more separate network requests. The bigger the chunk size though, the more likely any particular is to fail.

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.

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!