アップロードするファイルとGoogleドライブに空のファイルがあります。私はGoogleのAPIクライアントにGoogle Apiclient、Googleドライブ、アップロードしたファイルを空にした後
"name": "google/apiclient",
"version": "1.1.7",
をインストールし、GoogleのDICSにアップロードファイルを試してみてください 私はHWIOバンドルとアクセストークンの助けを得る、
scope:
"https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/drive"
スコープを追加し、このようaccesTokenを取得
を理解しないのはなぜ
{"access_token":"TOKEN", "refresh_token":"TOKEN", "token_type":"Bearer",
"expires_in":3600, "id_token":"TOKEN", "created":1320790426}
beignアップロードしようとしているファイル(doc、pdf、私は理由は "名前" で、このdoc v3を使用
/tmp/phpaPpHBp
:「グーグル/ IMG)
$client = $this->get('artel.google.api.client');
/** @var CodeUserReference[] $accessToken */
$accessToken = $this->get('doctrine.orm.entity_manager')->getRepository('ArtelProfileBundle:CodeUserReference')
->getReferenceAccessClient($user);
if ($accessToken) {
$client->setAccessToken($accessToken[0]->getAccessTokenClient());
} else {
$view = $this->view(['No accessToken was found for this user id'], 400);
return $this->handleView($view);
}
$service = new \Google_Service_Drive($client->getGoogleClient());
$file = new \Google_Service_Drive_DriveFile();
$file->setName($request->request->get('title')
? $request->request->get('title')
: $request->files->get('file')->getClientOriginalName()
);
$file->setDescription($request->request->get('description'));
$file->setMimeType($request->request->get('mimeType')
? $request->request->get('mimeType')
: $request->files->get('file')->getClientMimeType()
);
// Set the parent folder.Google_Service_Drive_ParentReferen, this class not find in google/apiclient, version": "1.1.7", I don\'t know why..(
if ($request->request->get('parentId') != null) {
$parent = new Google_Service_Drive_ParentReferen();
$parent->setId($request->request->get('parentId'));
$file->setParents(array($parent));
}
try {
$data = $request->files->get('file');
$createdFile = $service->files->create($file, array(
'data' => $data,
'mimeType' => $request->request->get('mimeType')
? $request->request->get('mimeType')
: $request->files->get('file')->getClientMimeType(),
'uploadType' => 'media'
));
// Uncomment the following line to print the File ID
// print 'File ID: %s' % $createdFile->getId();
return View::create()
->setStatusCode(200)
->setData([$createdFile]);
} catch (\Exception $e) {
$view = $this->view((array) $e->getMessage(), 400);
return $this->handleView($view);
}
は応答
{
"internal_gapi_mappings": [],
"model_data": [],
"processed": [],
"collection_key": "spaces",
"capabilities_type": "Google_Service_Drive_DriveFileCapabilities",
"capabilities_data_type": "",
"content_hints_type": "Google_Service_Drive_DriveFileContentHints",
"content_hints_data_type": "",
"id": "0B2_i_Tc5Vr8UWV9Jc2psQkhqS3M",
"image_media_metadata_type": "Google_Service_Drive_DriveFileImageMediaMetadata",
"image_media_metadata_data_type": "",
"kind": "drive#file",
"last_modifying_user_type": "Google_Service_Drive_User",
"last_modifying_user_data_type": "",
"mime_type": "application/msword",
"name": "Resume — Symfony Backend Developer, PHP, Shuba Ivan.doc",
"owners_type": "Google_Service_Drive_User",
"owners_data_type": "array",
"permissions_type": "Google_Service_Drive_Permission",
"permissions_data_type": "array",
"sharing_user_type": "Google_Service_Drive_User",
"sharing_user_data_type": "",
"video_media_metadata_type": "Google_Service_Drive_DriveFileVideoMediaMetadata",
"video_media_metadata_data_type": ""
}
ファイルに私が持っているすべてを持っていますapiclient "、" version ":" 1.1.7 "関数が見つからない" insert "、
だから、これだけのように、正しいけどemty内MIME_TYPE - 私はいくつかのuploadTypeを試しに/ tmp/phpaPpHBp - メディア、マルチパート、再開可能なもののSTIL空 トライのPDF MIME_TYPE =アプリケーション/ PDFそれでもemty 私は\何間違っていると私はなぜGoogleドライブにemtyファイルがありますか?知っている
誰でも、