Вы не можете загрузить файл презентации в Google Презентации. Вам необходимо импортировать файл на Google Диск с помощью типа Google Doc. Взгляните на reference documentation, в котором есть пример того, как этого достичь. Вот примеры того, как достичь того, что вам нужно.
PPT в Google Слайды презентации:
$service = new Google_Service_Drive($client);
// CREATE A NEW FILE
$file = new Google_Service_Drive_DriveFile(array(
'name' => 'PPT Test Presentation',
'mimeType' => 'application/vnd.google-apps.presentation'
));
$ppt = file_get_contents("SamplePPT.ppt"); // read power point ppt file
//declare opts params
$optParams = array(
'uploadType' => 'multipart',
'data' => $ppt,
'mimeType' => 'application/vnd.ms-powerpoint'
);
//import pptx file as a Google Slide presentation
$createdFile = $service->files->create($file, $optParams);
//print google slides id
print "File id: ".$createdFile->id;
PPTX в Google Слайды презентации:
$service = new Google_Service_Drive($client);
// CREATE A NEW FILE
$file = new Google_Service_Drive_DriveFile(array(
'name' => 'PPTX Test Presentation',
'mimeType' => 'application/vnd.google-apps.presentation'
));
$pptx = file_get_contents("SamplePPTX.pptx"); // read power point pptx file
//declare opts params
$optParams = array(
'uploadType' => 'multipart',
'data' => $ppt,
'mimeType' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation'
);
//import pptx file as a Google Slide presentation
$createdFile = $service->files->create($file, $optParams);
//print google slides id
print "File id: ".$createdFile->id;
PDF в Google Документ Doc: (нет возможности Google Slide презентации)
$service = new Google_Service_Drive($client);
// CREATE A NEW FILE
$file = new Google_Service_Drive_DriveFile(array(
'name' => 'PDF Test Document',
'mimeType' => 'application/vnd.google-apps.document'
));
$pdf = file_get_contents("SamplePDF.pdf"); // read pdf file
//declare opts params
$optParams = array(
'uploadType' => 'multipart',
'data' => $pdf,
'mimeType' => 'application/pdf'
);
//import pdf file as a Google Document File
$createdFile = $service->files->create($file, $optParams);
//print google document id
print "File id: ".$createdFile->id;
Единственное, что меняется в каждом фрагменте кода, это mimeType
. Для справки Mime Types вы можете visit here и для справки из Mime Types Google вы можете visit here.
Did'nt work! ( –
Какой из них не сработал? Pptx? – Morfinismo
Да. Не работал с pptx. –