You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.

Forum Discussion

narner's avatar
narner
Explorer | Level 4
6 years ago

Route error for shared link - SwiftyDropbox

I'm using the Dropbox Swift SDK in my iOS app, and am currently trying to figure out what the proper response is for an error I've encountered. 

My basic flow is that a PDF gets uploaded to the app's folder in Dropbox, and then a shared link is retrieved for that file. Below is my code for this:

     

        let request = client!.files.upload(path: "/My.pdf", input: pdf)
            .response { response, error in
                if let response = response {
                    print(response)
                } else if let error = error {
                    print(error)
                }
            }
            .progress { progressData in
                print(progressData)
        }
        
        client?.sharing.createSharedLinkWithSettings(path: "/Pinch.pdf").response { response, error in
            if let link = response {
                self.pinchDropboxLink = link.url
                print(link)
            } else {
                print(error!)
            }
        }

This works as expected the first time. However, on the second time the code runs, I get this response...which occurs repeadelty, even after I've  manually deleted the old file from the Dropbox folder:

 

API route error - {
    ".tag" = path;
    reason =     {
        ".tag" = conflict;
        conflict =         {
            ".tag" = file;
        };
    };
    "upload_session_id" = "AAAAAAAAIWbPobc-HKe-gA";
}
API route error - {
    ".tag" = "shared_link_already_exists";
}

What's the best way to resolve this / work around in this scenario? 

 

 

 

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Staff rankDropbox Staff

    [Cross-linking for reference: https://stackoverflow.com/questions/56569788/route-error-for-shared-link-swiftydropbox ]

    When uploading a file using upload, the 'path/conflict/file' error means that "There’s a file in the way.". That's expected after the initial upload. Unless you need to change the file's contents, you don't need to make the upload call again.

    If you delete the file, the upload call should work again once. You mentioned you deleted the file before trying this again, but please double check that you deleted the correct one. For instance, if your app is registered for the "app folder" permission, your app will upload inside its own special app folder, by default at "/Apps/<app folder name>".

    Likewise, once you've already created a shared link for a file, you can't create another one. You'll get the 'shared_link_already_exists' error if you try to do so. You can instead retrieve existing shared links using listSharedLinks.

    • narner's avatar
      narner
      Explorer | Level 4

      Hey Greg, thanks for the info here!

      Hmm, yes; I double checked the app's folder and made sure to delete the file from there, but the error still seems to occur just the same. 

      Additionally, what I'm needing to do is upload the *modifications* to the file...is there a way to upload changes to a file in addition to keeping the shared link? 

      Thank you!

      • Greg-DB's avatar
        Greg-DB
        Icon for Dropbox Staff rankDropbox Staff

        If you're deleting the file first, you shouldn't get the conflict error. I'll follow up with you privately to try to troubleshoot that directly.

        And yes, to upload new versions of an existing file, you should use upload again. You should send the data for the new version of the file, and specify the 'update' (preferably), or otherwise 'overwrite', WriteMode as the 'mode' parameter. That won't interfere with the shared link. The existing shared link will reference the latest version of the file.

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

5,915 PostsLatest Activity: 10 minutes ago
333 Following

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 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!