Swift: Downloading Images from DropBox

518 views Asked by At

enter image description here

Here's the code I've tried so far:

client?.files.download(path: "/AlloyTest/\(imageName)").response { response, error in
    if let response = response {
      let responseMetadata = response.0
      print(responseMetadata)
      let fileContents = response.1
      print(fileContents)
    } else if let error = error {
      print(error)
    }
  }
  .progress { progressData in
    print(progressData)
  }

This is the error I'm getting when trying the function below:

API route error - {
  ".tag" = path;
  path =   {
    ".tag" = "not_found";
  };
} 

NEW CODE

func getImage(imageName: String, completion: @escaping (UIImage, NetworkingError) -> ()) {
    // Get Image from dropbox
    // Download to Data
    client?.files.listFolder(path: "/AlloyTest").response { response, error in
      if let response = response {
        let entries = response.entries
        print("ENTRIES:", entries)
      } else if let error = error {
        print(error)
      }
    }
  }
1

There are 1 answers

2
Greg On

A path/not_found error indicates that there was nothing at the specified path, in this case "/AlloyTest/\(imageName)", in the connected Dropbox account. Make sure you provide the correct path.

For example, you can list the contents of any particular folder to get the correct path values of its contents using listFolder/listFolderContinue. The path for any particular returned item is Metadata.pathLower.