Reputation: 1372
I am trying to retrieve an image located in a Google Drive using the PHP API. Authorisation works, but I cannot seem to figure out how to get the image file to place it in a folder. I have not found any results online.
Currently using
$driveService->files->get($fileId)
,
where $driveService is a Google_Service_Drive class.
Then I'm trying to use the webContentLink to use it to download the file, but webContentLink is being set to null. The image is located in a folder with edit permissions given to a service account, which is being used to access the images.
Upvotes: 1
Views: 993
Reputation: 117016
webContentLink is only available for binary files. If you are using file.get you can just write the get the body and write it out to the file.
$file = $service->files->get($fileId, array('alt' => 'media'));
file_put_contents("hello.pdf",$file->getBody());
Upvotes: 1