【问题标题】:Copying files from Google Drive Server to Own server directly将文件从 Google Drive Server 直接复制到自己的服务器
【发布时间】:2018-05-08 17:57:07
【问题描述】:

我正在尝试将文件从 Google 云端硬盘链接从 Google 服务器下载到我的网络服务器,以避免 PHP POST 中的最大大小为 100。

<?php
$link = $_POST["linkToUpload"];

$upload = file_put_contents("uploads/test".rand().".txt", fopen($link, 'r'));
header("Location: index.php");
?>

插入像http://example.com/text.txt 这样的普通链接可以正常工作。问题来自链接谷歌驱动器https://drive.google.com/uc?authuser=0&amp;id=000&amp;export=download。这是来自 Google Drive 的直接链接,但它不起作用。所以我尝试插入我获得的在本地下载文件的链接https://doc-08-bo-docs.googleusercontent.com/docs/securesc/000/000/000/000/000/000?e=download,但它仍然无法正常工作。你认为谷歌试图避免服务器到服务器的复制吗?还是有其他方法可以做到?

【问题讨论】:

    标签: php html google-drive-api


    【解决方案1】:

    如果您想使用自己的应用程序获取文件,您应该使用 API(应用程序编程接口)来获取这些文件。

    看看file download documentation for Google Drive

    在 PHP 中下载 sn-p 示例:

    $fileId = '0BwwA4oUTeiV1UVNwOHItT0xfa2M';
    $response = $driveService->files->get($fileId, array(
        'alt' => 'media'));
    $content = $response->getBody()->getContents();
    

    【讨论】:

      猜你喜欢
      • 2013-06-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-06-15
      • 2019-07-08
      • 1970-01-01
      • 2016-09-23
      相关资源
      最近更新 更多