@@ -347,14 +347,13 @@ public function findById(string $fileId)
347347 * Download a file
348348 *
349349 * @param string $fileId File to download Id
350- * @param string $path
351- * @param bool $googleDocument Determine if the file is a Google Document
350+ * @param string $filepath The path where te file will be store
352351 *
353352 * Warning : the path start inside the public directory (need to create manually the 'downloads/' folder)
354353 *
355- * @return bool
354+ * @return string $filepath
356355 */
357- public function downloadFile (string $ fileId , bool $ googleDocument = true , string $ filepath = 'downloads/ ' )
356+ public function downloadFile (string $ fileId , string $ filepath = 'downloads/ ' )
358357 {
359358 $ drive = $ this ->getDrive ();
360359
@@ -363,8 +362,9 @@ public function downloadFile(string $fileId, bool $googleDocument = true, string
363362
364363 // Check for extension
365364 $ filename = (isset (pathinfo ($ filename )['extension ' ])) ? $ filename : $ filename . '. ' . $ driveFile ->getFileExtension ();
366-
367- if ($ googleDocument === false ) {
365+
366+ // Differents exports links already set up for Google documents
367+ if ($ driveFile ->getExportLinks () === null ) {
368368 $ response = $ drive ->files ->get ($ driveFile ->getId (), array (
369369 'alt ' => 'media ' ));
370370 } else {
@@ -377,11 +377,13 @@ public function downloadFile(string $fileId, bool $googleDocument = true, string
377377 $ filename = $ driveFile ->getName () . $ fileInfos ['extension ' ];
378378 }
379379
380+ $ filepath .= $ filename ;
381+
380382 $ fileContent = $ response ->getBody ()->getContents ();
381383
382- file_put_contents ($ filepath . $ filename , $ fileContent );
384+ file_put_contents ($ filepath , $ fileContent );
383385
384- return true ;
386+ return $ filepath ;
385387 }
386388
387389 /**
0 commit comments