如何获得的文件URL上传到谷歌驱动SDK使用php


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

我使用Google Drive SDK通过PHP上传文件。现在我想获得链接作为字符串,以便我可以将其存储在我的数据库中。但是我不知道怎么得到它。这是在google drive中使用PHP创建文件的代码。

$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