Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 错误500-获取下载驱动器.files.export_Ios_Objective C_Google Drive Api - Fatal编程技术网

Ios 错误500-获取下载驱动器.files.export

Ios 错误500-获取下载驱动器.files.export,ios,objective-c,google-drive-api,Ios,Objective C,Google Drive Api,我遇到了一个谷歌硬盘文件大小超过5MB(可能?)的问题。我试图下载它们并将其导出为application/pdf,但遇到了错误500 我正在使用以下代码检索和下载驱动器文件(doc、ppt或xls): 下面是我使用GTMSessionFetcher获取的日志: Download drive.files.export 2017-03-30 22:37:50 +0000 elapsed: 29.406sec Request: GET https://www.googleapis.com/driv

我遇到了一个谷歌硬盘文件大小超过5MB(可能?)的问题。我试图下载它们并将其导出为
application/pdf
,但遇到了错误500

我正在使用以下代码检索和下载驱动器文件(doc、ppt或xls):

下面是我使用
GTMSessionFetcher
获取的日志:

Download drive.files.export

2017-03-30 22:37:50 +0000  elapsed: 29.406sec
Request: GET https://www.googleapis.com/drive/v3/files/[fileID]/export?alt=media&mimeType=application%2Fpdf
Request headers:
  Accept: application/json
  Authorization: Bearer _snip_
  Cache-Control: no-cache
  Content-Type: application/json; charset=utf-8
  User-Agent: org.cocoapods.GoogleAPIClientForREST/1.2.1 google-api-objc-client/3.0 iPhone/10.2 hw/sim (gzip)

Response: status 500
Response headers:
  Cache-Control: private, max-age=0
  Content-Encoding: gzip
  Content-Length: 123
  Content-Type: application/json; charset=UTF-8
  Date: Thu, 30 Mar 2017 22:37:50 GMT
  Expires: Thu, 30 Mar 2017 22:37:50 GMT
  Server: GSE
  Vary: Origin, X-Origin
  alt-svc: quic=":443"; ma=2592000; v="37,36,35"
  x-content-type-options: nosniff
  x-frame-options: SAMEORIGIN
  x-xss-protection: 1; mode=block

Response body: (180 bytes)
{
  "error" : {
    "message" : "Internal Error",
    "errors" : [
      {
        "reason" : "internalError",
        "message" : "Internal Error",
        "domain" : "global"
      }
    ],
    "code" : 500
  }
}
值得一提的是,在我看来,当服务器抛出这个错误时,有30秒的服务器限制-500秒。对于大小小于5 MB的文件,它正在正确地执行此操作,并且我能够取回pdf文件。这通常在30秒内完成,也意味着这不是身份验证问题

我还尝试将mimeType更改为
vnd.openxmlformats officedocument.wordprocessingml.document
,我会得到一个403错误,上面写着
“消息”:“此文件太大,无法导出。”

你知道怎么解决这个问题吗


谢谢。

500错误通常是由于内部驱动器基础结构中的超时造成的。这与你所看到的症状是一致的。因此,一个大文件需要很长时间才能呈现为.pdf格式,以至于基础设施超时


标准建议是使用指数退避算法对500个错误进行退避和重试。在您的情况下,我建议从5秒开始退避,一旦退避并重试30秒,如果仍然失败,您应该放弃。

www.googleapis.com
未找到。这只是一个例子,还是你真的使用了它?我删除了文件ID,因为除非你得到授权,否则你将无法访问它。文件ID为1IrCPpb8H6GtfsvtbtqK7q4x8IxX0_C2UQC1Xaovyah4您是否能够使用drive.google.com上的web应用程序将此文件导出为pdf?是的,这样做需要30秒以上的时间,因此他们必须执行其他操作才能正常工作。什么类型的文件出现问题(文档、工作表、幻灯片)?你怎么知道它是5MB?我可以做指数退避,但我不认为这能解决问题(很可能它总是失败)。网络版可以做到这一点。另外,我们并不是在谈论100MB的文件,测试用例是5.2MB,但它失败了。我怀疑你是对的,但是退避和重试实际上是你盒子里唯一的工具。这种想法是,您可能会运气好,发现失败尝试的pdf输出已缓存在驱动器基础结构中的某个位置,因此后续导出速度要快得多。如果这不能让你出狱,你就会被一个驱动程序错误缠住。
Download drive.files.export

2017-03-30 22:37:50 +0000  elapsed: 29.406sec
Request: GET https://www.googleapis.com/drive/v3/files/[fileID]/export?alt=media&mimeType=application%2Fpdf
Request headers:
  Accept: application/json
  Authorization: Bearer _snip_
  Cache-Control: no-cache
  Content-Type: application/json; charset=utf-8
  User-Agent: org.cocoapods.GoogleAPIClientForREST/1.2.1 google-api-objc-client/3.0 iPhone/10.2 hw/sim (gzip)

Response: status 500
Response headers:
  Cache-Control: private, max-age=0
  Content-Encoding: gzip
  Content-Length: 123
  Content-Type: application/json; charset=UTF-8
  Date: Thu, 30 Mar 2017 22:37:50 GMT
  Expires: Thu, 30 Mar 2017 22:37:50 GMT
  Server: GSE
  Vary: Origin, X-Origin
  alt-svc: quic=":443"; ma=2592000; v="37,36,35"
  x-content-type-options: nosniff
  x-frame-options: SAMEORIGIN
  x-xss-protection: 1; mode=block

Response body: (180 bytes)
{
  "error" : {
    "message" : "Internal Error",
    "errors" : [
      {
        "reason" : "internalError",
        "message" : "Internal Error",
        "domain" : "global"
      }
    ],
    "code" : 500
  }
}