Skip to content

Instantly share code, notes, and snippets.

@srmd-tl
Created December 2, 2020 05:09
Show Gist options
  • Save srmd-tl/ed524d50b982d7905e582a27563ed404 to your computer and use it in GitHub Desktop.
Save srmd-tl/ed524d50b982d7905e582a27563ed404 to your computer and use it in GitHub Desktop.
Upload files to google drive
// Get the API client and construct the service object.
$client = self::getClient();
$service = new Google_Service_Drive($client);
// Now lets try and send the metadata as well using multipart!
$file = new Google_Service_Drive_DriveFile();
$file->setName("Hello World!");
$result2 = $service->files->create(
$file,
array(
'data' => file_get_contents(request()->file),
'mimeType' => 'application/octet-stream',
'uploadType' => 'multipart'
)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment