Skip to content

Instantly share code, notes, and snippets.

@plehr
Last active December 17, 2016 12:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save plehr/0503f55f200f8fe3a61e3143d6e685f7 to your computer and use it in GitHub Desktop.
Save plehr/0503f55f200f8fe3a61e3143d6e685f7 to your computer and use it in GitHub Desktop.
function newfolder($drive_service){
$fileMetadata = new Google_Service_Drive_DriveFile(array(
'name' => 'Testordner',
'mimeType' => 'application/vnd.google-apps.folder'));
$file = $drive_service->files->create($fileMetadata, array(
'fields' => 'id'));
printf("Folder ID: %s\n", $file->id); }
function ($drive_service) {
$folderId = 'xxxxxxxxxxx';
$fileMetadata = new Google_Service_Drive_DriveFile(array(
'name' => 'test.pdf'
));
$content = file_get_contents('doc.pdf');
$file = $drive_service->files->create($fileMetadata, array(
'data' => $content,
'mimeType' => 'application/pdf',
'uploadType' => 'multipart',
'fields' => 'id'));
printf("File ID: %s\n", $file->id);}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment