update existing file in google drive

I can upload regular files. No problem here.
I get an error when updating existing files
I added ‘uploadType’ => ‘multipart’ and it gave an error again.

There is a “.htaccess” file in the directory and it says “deny from all” in its content.
I delete it from the “.htaccess” drive and it gives an error in another file.

An example error message:
Google\Service\Drive\Resource\Files->update( $fileId = '1ouvREdK6mJSOu_AqGyffcuwFvmvHM4Ar', $postBody = NULL, $optParams="deny from all", [] )
Error in another file shows file content

second line gives error
$content = file_get_contents($filePath); $service->files->update($existingFile->getId(), null, $content, []);

I am using a Google Drive Service Account
and I am using the php 8.2 version library

  • In your situation, what is the mimeType of $existingFile->getId()? And, what is the value of file_get_contents($filePath)?

    – 

  • I tried as below $content = file_get_contents($filePath); $service->files->update($existingFile->getId(), null, $content, [ 'mimeType' => 'application/octet-stream', 'uploadType' => 'multipart', ]);

    – 




  • Thank you for replying. I have to apologize for my poor English skill. Unfortunately, from I tried as below $content = file_get_contents($filePath); $service->files->update($existingFile->getId(), null, $content, [ 'mimeType' => 'application/octet-stream', 'uploadType' => 'multipart', ]);, I couldn’t understand the answers to my 2 questions.

    – 

Leave a Comment