I managed to do this, you should put an empty file as the second argument, you donβt know why, but this post helped me a lot: Google Drive API v3 Migration
This is the final solution:
function updateFile($service, $fileId, $data) { try { $emptyFile = new Google_Service_Drive_DriveFile(); $service->files->update($fileId, $emptyFile, array( 'data' => $data, 'mimeType' => 'text/csv', 'uploadType' => 'multipart' )); } catch (Exception $e) { print "An error occurred: " . $e->getMessage(); } }
where $ fileId is the file that you are updating, and data is the new content that you are updating.
Do not forget to update Google Drive after that, because its viewing does not change, and I lost one hour: /. Hope this helps.
MapleSyrup
source share