[英]I can't see the files and folders created via api in my Google Drive using php
[英]How to see files uploaded to google drive via PHP?
我一直试图使用php通过service-account将文件上传到我的Google Drive帐户。 我猜该文件已成功上传,因为我可以打印文件ID,文件创建时间和所有其他信息。
这是我的问题:登录到Google云端硬盘帐户后,看不到任何上传的文件。 文件隐藏在哪里或该怎么办?
这是代码:
require __DIR__ . '/vendor/autoload.php'; //api
$serviceAccount = "xxx@xxxxxx.iam.gserviceaccount.com";
$key_file = "mykey-goes-here.p12";
$auth = new Google_Auth_AssertionCredentials(
$serviceAccount,
array('https://www.googleapis.com/auth/drive.file'),
file_get_contents($key_file)
);
$client = new Google_Client();
$client->setAssertionCredentials( $auth );
$service = new Google_Service_Drive($client);
$file = new Google_Service_Drive_DriveFile();
$file->setTitle("my file name");
$file->setDescription('testing desc');
$file->setMimeType('text/plain');
// Provide file name here and path in below
$result = $service->files->insert($file, array(
'data' => file_get_contents("test.txt"),
//'mimeType' => 'text/plain',
'mimeType' => 'application/octet-stream',
'uploadType' => 'media',
//'uploadType' => 'multipart'
));
// Uncomment the following line to print the File ID
printf("File ID: %s\n", $result->id);
echo "<br><br>";
echo '<pre>'; print_r($result); echo'</pre>';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.