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

petepete717's avatar
petepete717
Helpful | Level 6
3 years ago

malformed_path error in Swift

I am attempting to upload a file in Swift. The issue I have is that when I name the file with a string that I define myself, it works.

But when I extract the file from the URL the upload does not work. Here is my code:

 

let filename = "testfile.pdf"

 

// example that does not work:

// url is .../something/testfile.pdf

// let filename = url.lastpathcomponent

 

if let client = DropboxClientsManager.authorizedClient {

            client.files.upload(path: filename,

                                mode: .overwrite,

                                autorename: false,

                                clientModified: nil,

                                mute: true,

                                input: pdf

            )

}

 

The error message:

API route error - {

    ".tag" = path;

    reason =     {

        ".tag" = "malformed_path";

    };

    "upload_session_id" = "pid_upload_session:...";

}

 

It seems as if the string value I receive in url.lastpathcomponent is not a format that can be read by SwiftyDropbox. But the strings seem identical. What do I need to change?

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: 14 hours 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!