如何使用 php 在 google Drive SDK 中获取上传的文件 URL

How to get the file URL uploaded in google drive SDK using php

我正在使用 Google Drive SDK 通过 PHP 上传文件。现在我想获取 Link 作为字符串,以便我可以将它存储在我的数据库中。但我不知道如何获取它。这是使用 PHP.

在 google 驱动器中创建文件的代码
$file = new Google_DriveFile();
$file->setTitle( 'new_pdf' );
$file->setMimeType( 'application/pdf' );
$createdFile = $service->files->insert( $file, array(
    'data' => $stringContent,
));

您需要 $createdFile 的属性之一。

属性列表位于 https://developers.google.com/drive/v2/reference/files

您可能想要 webContentLink,但这取决于您打算如何使用 URL。