Reputation: 23
Thanks for your time,
I have this code:
$googleClient = Google::getClient();
$googleClient->setApplicationName("aiesec");
$googleClient->setScopes(\Google_Service_Drive::DRIVE);
//$googleClient->setSubject('stivenson.rpm@gmail.com');
$googleClient->setAuthConfig('/opt/lampp/htdocs/aiesec/administration/aiesec-34835b27733e.json');
$service = new \Google_Service_Drive($googleClient);
$himage = new Image; // only is helper class
$file = new \Google_Service_Drive_DriveFile();
$file->setName($attr['names'].' '.$attr['last_names']);
$file->setDescription('Foto de '.$attr['names'].' '.$attr['last_names'].' desde App');
$file->setMimeType('image/'.$himage->getMime($photo));
$createdFile = $service->files->create($file, [
'data' => file_get_contents($himage->getPath($photo)),
'mimeType' => 'image/'.$himage->getMime($photo),
'uploadType' => 'multipart'
]);
And I Have this answer
Google_Service_Drive_DriveFile Object ( [collection_key:protected] => spaces [appProperties] => [capabilitiesType:protected] => Google_Service_Drive_DriveFileCapabilities [capabilitiesDataType:protected] => [contentHintsType:protected] => Google_Service_Drive_DriveFileContentHints [contentHintsDataType:protected] => [createdTime] => [description] => [explicitlyTrashed] => [fileExtension] => [folderColorRgb] => [fullFileExtension] => [headRevisionId] => [iconLink] => [id] => 0B5hHgJxzNMhpak5WVlBLa3ZsdUk [imageMediaMetadataType:protected] => Google_Service_Drive_DriveFileImageMediaMetadata [imageMediaMetadataDataType:protected] => [isAppAuthorized] => [kind] => drive#file [lastModifyingUserType:protected] => Google_Service_Drive_User [lastModifyingUserDataType:protected] => [md5Checksum] => [mimeType] => image/jpeg [modifiedByMeTime] => [modifiedTime] => [name] => Stivenson Rincon Mora [originalFilename] => [ownedByMe] => [ownersType:protected] => Google_Service_Drive_User [ownersDataType:protected] => array [parents] => [permissionsType:protected] => Google_Service_Drive_Permission [permissionsDataType:protected] => array [properties] => [quotaBytesUsed] => [shared] => [sharedWithMeTime] => [sharingUserType:protected] => Google_Service_Drive_User [sharingUserDataType:protected] => [size] => [spaces] => [starred] => [thumbnailLink] => [trashed] => [version] => [videoMediaMetadataType:protected] => Google_Service_Drive_DriveFileVideoMediaMetadata [videoMediaMetadataDataType:protected] => [viewedByMe] => [viewedByMeTime] => [viewersCanCopyContent] => [webContentLink] => [webViewLink] => [writersCanShare] => [internal_gapi_mappings:protected] => Array ( ) [modelData:protected] => Array ( ) [processed:protected] => Array ( ) )
But the file not upload ... What do I need? Thanks for your time again ...
Upvotes: 0
Views: 143
Reputation: 2998
Its possible that the PHP client (beta) is still using v2 APIs (when I checked the PHP docs about it). Try out to use insert
instead of create
.
Additionally, a similar question was also asked about the contents not being added, and was solved when you set the mimeType as application/octet-stream
.
Upvotes: 0