Your workflow is unique 👨‍💻 -  tell us how you use Dropbox here.

Forum Discussion

m. name's avatar
m. name
New member | Level 1
10 years ago

How can I upload PDF by SwiftyDropbox?

I am new to SwiftyDropbox.

I attempted to upload PDF from iOS App.

func uploadPDF(filename: String, fullPath: String){  
    if let data = NSData(contentsOfFile: fullPath){  
    client.filesUpload(path: filename, body: data).response{ response, error in  
    if let metadata = response {  
    println("Uploaded file name: \(metadata.name)")  
    println("Uploaded file revision: \(metadata.rev)")  
    // Get file (or folder) metadata  
    self.client.filesGetMetadata(path: filename).response { response, error in  
    if let metadata = response {  
    println("Name: \(metadata.name)")  
    if let file = metadata as? Files.FileMetadata {  
    println("This is a file.")  
    println("File size: \(file.size)")  
    } else if let folder = metadata as? Files.FolderMetadata {  
    println("This is a folder.")  
    }  
    } else {  
    println(error!)  
    }  
    }  
    } else {  
    println(error!)  
    }  
    }  
    }   
}


However, response is error.

Bad Input: Error in call to API function "files/upload": HTTP header "Dropbox-API-Arg": could not decode input as JSON


What can I do?

8 Replies

Replies have been turned off for this discussion
  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    10 years ago

    Is that the actual file name, or have you redacted the part before the extension for privacy reasons? We've been able to reproduce this issue when there are unicode characters in the filename, but we'd like to verify if that is or isn't the same case you're seeing.

  • m. name's avatar
    m. name
    New member | Level 1
    10 years ago

    Thank you for the reply.

    Certainly, the filename contains unicode characters.

    I was able to upload the file with filename not containing unicode characters. However, preview in dropbox doesn't work showing unicode characters.

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    10 years ago

    Thanks for confirming that! We're working on it.

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!