* Creates a new file with the metadata and contents * in the request body. Requires login. */ $app->post('/svc', function () use($app, $client, $service) { checkUserAuthentication($app); $inputFile = json_decode($app->request()->getBody()); try { $file = new Google_DriveFile(); $file->setTitle($inputFile->title); $file->setDescription($inputFile->description); $file->setMimeType($mimeType); // Set the parent folder. if ($inputFile->parentId != null) { $parentsCollectionData = new Google_DriveFileParentsCollection(); $parentsCollectionData->setId($inputFile->parentId); $file->setParentsCollection(array($parentsCollectionData)); } $createdFile = $service->files->insert($file, array('data' => $inputFile->content, 'mimeType' => $mimeType)); renderJson($app, $createdFile->id); } catch (Exception $ex) { renderEx($app, $ex); } }); /** * Modifies an existing file given in the request body and responds * with the file id. Requires login. */ $app->put('/svc', function () use($app, $client, $service) { checkUserAuthentication($app); $inputFile = json_decode($app->request()->getBody()); $fileId = $inputFile->id;