2013-03-09 635 views
3

我想知道上传后的文件ID。从文件列表中找到它,我认为这不是好主意和性能。所以,我怎样才能得到好的想法文件ID?如何在将文件上传到Google Drive后获取文件ID?

谢谢!

+0

按照[文件](https://developers.google.com/drive/v2/reference/files/insert)你从响应的ID,如:'文件文件= request.ResponseBody; Msgbox(file.Id)' – 2013-03-09 03:47:43

+0

我在响应中获得了它,谢谢! – 2013-03-09 05:58:10

回答

0

例如:

$file = new Google_Service_Drive_DriveFile(); 
$file->setName($fileTitle); 
$result = $service->files->create(
    $file, 
    array(
     'data' => file_get_contents(FILE), 
     'mimeType' => 'application/octet-stream', 
     'uploadType' => 'multipart' 
    ) 
); 

变量$结果包含关于上传文件的所有信息,因此,所有你需要做的就是展示或使用的ID。

echo 'Uploaded file id is '.$result['id']; 
相关问题