cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
What’s new: end-to-end encryption, Replay and Dash updates. Find out more about these updates, new features and more 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: 

Uploaded files are not in the Dropbox

Uploaded files are not in the Dropbox

sathish1995
Explorer | Level 3
Go to solution
@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.

1 Accepted Solution

Accepted Solutions

Greg-DB
Dropbox Staff
Go to solution
[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!

View solution in original post

3 Replies 3

Greg-DB
Dropbox Staff
Go to solution
[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!

sathish1995
Explorer | Level 3
Go to solution

I found my mistake! Thank you 

kyo
Explorer | Level 4
Go to solution

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) } } }
Need more support?
Who's talking

Top contributors to this post

  • User avatar
    kyo Explorer | Level 4
  • User avatar
    sathish1995 Explorer | Level 3
  • User avatar
    Greg-DB Dropbox Staff
What do Dropbox user levels mean?