Google app engine 无法使用PHP SDK将多个文件上载到Google drive

Google app engine 无法使用PHP SDK将多个文件上载到Google drive,google-app-engine,file-upload,google-drive-api,Google App Engine,File Upload,Google Drive Api,我正在尝试使用PHP SDK将多个文件上载到Google drive。为此,我反复调用下面的函数,传递所需的参数: function insertFile($driveService, $title, $description, $parentId, $fileUrl) { global $header; $file = new Google_DriveFile(); $file->setTitle($title); $file->setDescri

我正在尝试使用PHP SDK将多个文件上载到Google drive。为此,我反复调用下面的函数,传递所需的参数:

function insertFile($driveService, $title, $description, $parentId, $fileUrl) {
    global $header;

    $file = new Google_DriveFile();
    $file->setTitle($title);
    $file->setDescription($description);
    $mimeType= "application/vnd.google-apps.folder";

    if ($fileUrl != null) {
      $fileUrl = replaceSpaceWithHtmlCode($fileUrl);
      $header = getUrlHeader($fileUrl);
      $mimeType = $header['content-type'];
    }
    $file->setMimeType($mimeType);
    $parent = new Google_ParentReference();
    // Set the parent folder.
    if ($parentId != null) {
      $parent->setId($parentId);
      $file->setParents(array($parent));
    }

    try {
      $data = null;
      if ($fileUrl != null) {
        if (hasErrors($driveService, $fileUrl) == True) {
          return null;
        }
        $data = file_get_contents($fileUrl);
    }

    $createdFile = $driveService->files->insert($file, array(
      'data' => $data,
      'mimeType' => $mimeType,
    ));

      return $createdFile;
    } catch (Exception $e) {
        echo "Error: 12";
    return null;
    }
}
我正在谷歌应用程序引擎上运行此应用程序

但是,我无法上传我传递给它的所有文件。例如,如果我传递大约12-15个文件,只有10-11个文件被上传,有时所有文件都被上传,即使所有参数都是正确的。我发现了一个异常,它无法创建一个文件,这表明它无法创建一个文件,因为没有上传的文件。我在应用程序引擎的日志中没有看到任何警告或错误

我错过什么了吗?有人能告诉我,我应该在哪里纠正这一点,并使其足够可靠,上传所有文件给它

我尝试上载30个文件时得到的HTTP响应如下:

PHP Fatal error:  The request was aborted because it exceeded the maximum execution time

检查http响应以查看详细原因。这可能是因为你达到了油门极限,得到了403速率极限响应

日志中似乎没有任何内容表明已达到限制,如果问题是限制,我不确定是否会出现最后几个文件没有每次上载的情况,5个文件时上载4个,15个文件时上载13个。限制使用令牌桶工作。在令牌耗尽之前,大量插入都可以正常工作,在我的经验中大约是20个。之后,代币似乎以大约每2秒一枚的速度补充。任何使用空存储桶的插入尝试都将导致403异常。检查http响应。这看起来像是http超时。你能更改超时时间吗?我还建议(1)查看实际的http流量,不要只依赖日志,(2)尝试将插入速率降低到每3秒一次,看看这是否能解决问题。你能告诉我怎么更改超时时间吗?我试过每秒1次,但没什么区别,还是不可靠。每秒1次太快了。至少每3秒钟尝试一次,以确定这是否是原因。我不知道PHP-对不起。我建议问一个新问题“如何在appengine php上设置urlfetch的超时”。文件上说默认值是5s,这是非常低的。