【问题标题】:How to get all mime types Google Drive Api IOS如何获取所有 mime 类型 Google Drive Api IOS
【发布时间】:2012-10-09 14:32:07
【问题描述】:

我正在尝试为 IOS 集成 Google Drive Api。我正在测试他们的例子program here

a.k.a DrEdit 当他们上传或下载他们使用 mimetype 的文件时,例如他们上传文件时

[GTLUploadParameters uploadParametersWithData:fileContent MIMEType:@"text/plain"];

当 api 下载它使用的相同文件时

GTLQueryDrive *query = [GTLQueryDrive queryForFilesList]; query.q = @"mimeType = 'text/plain'";

文件的 JSON 值

{
  "kind": "drive#file",
  "id": string,
  "etag": etag,
  "selfLink": string,
  "title": "file_name",
  "mimeType": "mime/type",
  "description": "Stuff about the file"
  ...
  "downloadUrl": string,
  ...
}

现在我想知道如何下载用户文件夹中具有不同文件扩展名的所有文件,例如 pdf、doc 等...

如何显示/列出用户 google drive 帐户中的所有文档?

【问题讨论】:

  • 查看 Google Drive 的 docs 您可以查询所有文件(只读),也许您可​​以从那里选择要下载的文件。

标签: objective-c ios mime-types google-drive-api


【解决方案1】:

两件事:

1) 空查询似乎返回所有文件:

query.q = @"";

2) 确保您请求访问 auth (initWithScope:kGTLAuthScopeDrive) 中的所有文件。 DrEdit 示例默认只访问应用程序创建的文件。

GTMOAuth2ViewControllerTouch *authViewController = 
  [[GTMOAuth2ViewControllerTouch alloc] initWithScope:kGTLAuthScopeDrive    // Auth to all files and docs
                                             clientID:kClientId
                                         clientSecret:kClientSecret
                                     keychainItemName:kKeychainItemName
                                             delegate:self
                                     finishedSelector:finishedSelector];

【讨论】:

    【解决方案2】:

    Mime types

    我发现了谷歌驱动器支持的这种 mime 类型。您可以在下载或上传时使用它们。

    【讨论】:

      猜你喜欢
      • 2012-12-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-11-10
      相关资源
      最近更新 更多