cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Share your feedback on the Document Scanning Experience in the Dropbox App right here.

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: 

malformed_path error in Swift

malformed_path error in Swift

petepete717
Helpful | Level 6
Go to solution

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?

1 Accepted Solution

Accepted Solutions

Greg-DB
Dropbox Staff
Go to solution

You can find information on the required path format here: https://www.dropbox.com/developers/documentation/http/documentation#path-formats

 

I see you included a general description of how this is set up in the comments in your code, but if you need help debugging this, please share some actual code for reproducing this issue so we can investigate. Also, please print out and share the actual value of "filename" when this occurs for you.

View solution in original post

3 Replies 3

Здравко
Legendary | Level 20
Go to solution

Hi @petepete717,

You are passing filename instead of path to that file! 😉

Hope this helps.

Greg-DB
Dropbox Staff
Go to solution

You can find information on the required path format here: https://www.dropbox.com/developers/documentation/http/documentation#path-formats

 

I see you included a general description of how this is set up in the comments in your code, but if you need help debugging this, please share some actual code for reproducing this issue so we can investigate. Also, please print out and share the actual value of "filename" when this occurs for you.

petepete717
Helpful | Level 6
Go to solution

Thanks very much for pointing me in the right direction!

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    petepete717 Helpful | Level 6
  • User avatar
    Greg-DB Dropbox Staff
  • User avatar
    Здравко Legendary | Level 20
What do Dropbox user levels mean?