【问题标题】:Error Google Drive Insert API: Operation timed out错误 Google Drive Insert API:操作超时
【发布时间】:2017-06-24 03:15:52
【问题描述】:

调用 Google Drive API v2 (https://developers.google.com/drive/v2/reference/files/insert) 时出错:

$service->files->insert()     

我的脚本首先将文件上传到服务器,然后将文件上传到 Google Drive 存储。 它适用于小文件,但如果我尝试大文件(90-100 MB),我得到:

An error occurred: Operation timed out after 100000 milliseconds with 0 bytes received.

这是 Google 限制(文档:最大文件大小:5120GB)还是我需要设置任何 PHP 参数?
我使用上一个链接中包含的相同代码,并尝试在 php.ini 中增加此参数:

  • upload_max_filesize = 100M
  • post_max_size = 100M
  • max_execution_time = 300
  • max_input_time = 300
  • memory_limit = 1024M

文件已正确上传到服务器。

【问题讨论】:

    标签: php google-drive-api


    【解决方案1】:

    我无法帮助您使用 php,因为我不熟悉它。但是我在处理 .NET 项目时遇到了类似的问题。

    解决方案是设置 Drive 服务对象的Timeout 参数,如提到的here

    如果您看到此异常,请考虑在您的服务对象使用的客户端中手动增加 Timeout 属性。

    在 C# 中,代码类似于:

    service.HttpClient.Timeout = TimeSpan.FromMinutes(100);
    

    我记得必须引用System.Net.Http

    希望这能给您一些见解,并帮助您在 php 中修复它。

    【讨论】:

    • 谢谢!!我解决了在 google-api-php-client/src/Google/Config.php 中增加 Google_Config 的“request_timeout_seconds”参数。
    猜你喜欢
    • 1970-01-01
    • 2021-11-10
    • 2016-02-24
    • 2018-06-09
    • 1970-01-01
    • 2016-11-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多