Your workflow is unique 👨💻 - tell us how you use Dropbox here.
Forum Discussion
m. name
10 years agoNew member | Level 1
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
- Steve M.10 years ago
Dropbox Staff
Could you share the filename you're using?
- m. name10 years agoNew member | Level 1
Hi, Steve
filename is
/FILENAME.pdf - Greg-DB10 years ago
Dropbox Community Moderator
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. name10 years agoNew member | Level 1
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-DB10 years ago
Dropbox Community Moderator
Thanks for confirming that! We're working on it.
- m. name10 years agoNew member | Level 1
I understand. Thank you for your help.
- Greg-DB10 years ago
Dropbox Community Moderator
For reference, this was fixed here:
https://github.com/dropbox/SwiftyDropbox/commit/8fc2eed6f05af8a27a37cf76c244a0b56b065d85
That change should be included with the next release.
- m. name10 years agoNew member | Level 1
Thanks for your great work!
About 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!