구글 드라이브 API , google drive api
- https://developers.google.com/drive/web/about-sdk
- https://developers.google.com/drive/web/quickstart/php
-
PHP 5.3.2 <- 버전이 문제가 된다면 REST API기준으로 직접 구현해야겠지… 제길
- https://developers.google.com/api-client-library/php/
-
PHP version 5.2.1 or greater.
- https://developers.google.com/apis-explorer/?hl=ko#s/drive/v2/
- rest
-
실제 테스트가능
- https://developers.google.com/drive/v2/reference/files/insert
- rest 설명
지정된 폴더에 파일을 업로드 하는 방법 function insertFile($service, $title, $description, $parentId, $mimeType, $filename) { $file = new Google_Service_Drive_DriveFile(); $file->setTitle($title); $file->setDescription($description); $file->setMimeType($mimeType);
// Set the parent folder. if ($parentId != null) { $parent = new Google_Service_Drive_ParentReference(); $parent->setId($parentId); $file->setParents(array($parent)); }
try { $data = file_get_contents($filename);
$createdFile = $service->files->insert($file, array( ‘data’ => $data, ‘mimeType’ => $mimeType, ‘uploadType’ => ‘multipart’, ));
// Uncomment the following line to print the File ID // print ‘File ID: %s’ % $createdFile->getId();
return $createdFile; } catch (Exception $e) { print “An error occurred: “ . $e->getMessage(); } }
/* 폴더 만들기 참고 File body = new File(); body.setTitle(“title”); body.setMimeType(“application/vnd.google-apps.folder”); File file = service.files().insert(body).execute(); */