【问题标题】:Swift: Downloading Images from DropBoxSwift:从 DropBox 下载图像
【发布时间】:2020-05-26 17:14:35
【问题描述】:

这是我迄今为止尝试过的代码:

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)
  }

这是我在尝试以下功能时遇到的错误:

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

新代码

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)
      }
    }
  }

【问题讨论】:

    标签: ios swift dropbox dropbox-api swiftydropbox


    【解决方案1】:

    A path/not_found error 表示连接的 Dropbox 帐户中指定路径(在本例中为 "/AlloyTest/\(imageName)")处没有任何内容。确保提供正确的路径。

    例如,您可以使用listFolder/listFolderContinue 列出任何特定文件夹的内容以获取其内容的正确路径值。任何特定返回项目的路径是Metadata.pathLower

    【讨论】:

    • 我试过了,但我仍然遇到同样的错误。我编辑了我的问题并添加了更多信息以使事情更清楚。
    • 您可能正在使用带有“应用程序文件夹”permission 的应用程序,在这种情况下,您的 API 调用将仅在应用程序的应用程序文件夹内运行,默认情况下位于“/Apps/”。您可以使用空字符串 "" 的路径值来列出您的应用有权访问的根目录。如果您需要访问非应用文件夹位置,则需要 register 一个“完整的 Dropbox”应用。
    猜你喜欢
    • 2017-10-24
    • 1970-01-01
    • 2014-09-16
    • 1970-01-01
    • 1970-01-01
    • 2014-08-05
    • 1970-01-01
    相关资源
    最近更新 更多