cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
We want to hear from you. What projects do you use Dropbox for?
Close

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: 
Highlighted

Route error for shared link - SwiftyDropbox

Explorer | Level 4

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? 

 

 

 

3 Replies 3
Highlighted

Re: Route error for shared link - SwiftyDropbox

Dropboxer
Dropboxer

[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.

Highlighted

Re: Route error for shared link - SwiftyDropbox

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!

Highlighted

Re: Route error for shared link - SwiftyDropbox

Dropboxer
Dropboxer

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.

Polls
Do you know how to organize your files and folders?
We have created a guide on folder best practice, so you can get organized now check it out here.

Work Smarter with Dropbox

The way we work is changing. Share and discover new ways to work smarter with Dropbox in our community.

Sound good? Let's get started.
Who's talking

Top contributors to this post

What do Dropbox user levels mean?
Need more support?