We Want to Hear From You! What Do You Want to See on the Community? Tell us here!
Forum Discussion
sathish1995
9 years agoExplorer | Level 3
Uploaded files are not in the Dropbox
@IBAction func saveFile(_ sender: Any) { let client = DropboxClientsManager.authorizedClient let fileData = "testing data example".data(using: String.Encoding.utf8, allowLossyConversion: false)! let request = client?.files.upload(path: "/test/path/in/Dropbox/account", input: fileData).response { response, error in if let response = response { print("The upload response is \(response)") } else if let error = error { print("The upload error is \(error)") } } .progress { progressData in print(progressData) } // in case you want to cancel the request // if someConditionIsSatisfied { // request.cancel() print(" View Loaded ") }
Here I uploaded the file using the swift Language. It gave the uploaded response but the file is not there in the dropbox.
- [Cross-linking for reference: https://stackoverflow.com/questions/43917563/uploaded-files-are-not-in-dropbox ]
Can you share the full output you're getting? Thanks in advance!
3 Replies
Replies have been turned off for this discussion
- Greg-DB9 years ago
Dropbox Community Moderator
[Cross-linking for reference: https://stackoverflow.com/questions/43917563/uploaded-files-are-not-in-dropbox ]
Can you share the full output you're getting? Thanks in advance! - sathish19959 years agoExplorer | Level 3
I found my mistake! Thank you
- kyo9 years agoExplorer | Level 4
Here I am writing some code snippet. I decalared client as global and created a singleton class.
I hope this will help you.import SwiftyDropbox var clientDropBox = DropboxClient(accessToken: "Put Your Valid access token here.") class Dropboxmanager: NSObject { private init(client:DropboxClient) { clientDropBox = client } static let sharedInstance = Dropboxmanager(client: clientDropBox)
func dropboxSessionAndAuthorizationWithVC(vc:UIViewController) { DropboxClientsManager.authorizeFromController(UIApplication.shared, controller: vc, openURL: { (url) in UIApplication.shared.openURL(url) weak var wself = self OperationQueue.main.addOperation({ }) wself?.downloadFilesInDropBox() }) } func getCurrentUserInformation(completion:@escaping (String)-> Void) { // Get the current user's account info clientDropBox.users.getCurrentAccount().response(completionHandler: { (response, error) in if let account = response { print("Hello \(account.name.givenName)") completion(account.name.givenName) } else { print(error!) } }) }
func createFolderInDropBox(){ clientDropBox.files.createFolder(path: "/TempFolder").response { response, error in if let response = response { print(response) weak var wself = self wself?.uploadFilesInDropBox() } else if let error = error { print(error) } } }
func deleteDropBox(){ clientDropBox.files.delete(path: "/TempFolder/File.extension").response(completionHandler: { (response, error) in weak var wself = self wself?.uploadFilesInDropBox() }) } func getListOfFolder() { clientDropBox.files.listFolder(path: "").response { (response, error) in if let result = response { print("Folder contents:") for entry in result.entries { print(entry.name) } } else { print(error!) } } } func uploadFilesInDropBox(){ let strUrl = "URL_FILE" let url = URL(fileURLWithPath: strUrl) let _ = clientDropBox.files.upload(path: "", mode: Files.WriteMode.add, autorename: true, clientModified: Date(), mute: true, input: url).response { response, error in if let response = response { print(response) CoreDataManager.sharedInstance.deleteAllCoredataObjects() } else if let error = error { print(error) } } .progress { progressData in print(progressData) } } func downloadFilesInDropBox(){ // Download to URL let strUrl = "Destination Url" let destURL = URL(fileURLWithPath: strUrl) let destination: (URL, HTTPURLResponse) -> URL = { temporaryURL, response in return destURL } clientDropBox.files.download(path:"/TempFolder/File.extension", overwrite: true, destination: destination) .response { response, error in if let response = response { print(response) } else if let error = error { print(error) } } .progress { progressData in print(progressData) } } }
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.6,036 PostsLatest Activity: 2 days ago
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 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!