Google Drive SDK: Inserting a file results in Untitled in PHP

By : vicrabb

I do know about the two previous posts:

But apart from the answer 'are you sure you're using the latest release', none of the askers have come back to say if yes or no or if they've managed to find an answer.

Because I'm doing the same thing as them, I'm using the latest apiDriveService.php with the last revision dated from June 2012.

The data is correctly found but when you arrive at the insert line, clearly, something wrong happens.

And I don't understand why for the SDK php example, it seems to go correctly.

Is this a problem in the Google Api Console? Or do I need to encode the data in something special?

EDIT: in the apiDriveService file, I can see this line:

$this->files = new FilesServiceResource($this, $this->serviceName, 'files', json_decode('{"methods": {
"insert": {"scopes": ["", ""],
"parameters": {"convert": {"default": "false", "type": "boolean", "location": "query"}, "targetLanguage": {"type": "string", "location": "query"}, "sourceLanguage": {"type": "string", "location": "query"}, "ocrLanguage": {"type": "string", "location": "query"}, "pinned": {"default": "false", "type": "boolean", "location": "query"}, "ocr": {"default": "false", "type": "boolean", "location": "query"}, "timedTextTrackName": {"type": "string", "location": "query"}, "timedTextLanguage": {"type": "string", "location": "query"}}, "supportsMediaUpload": true, "request": {"$ref": "File"}, "mediaUpload": {"maxSize": "10GB", "accept": ["*/*"], "protocols": {"simple": {"path": "/upload/drive/v2/files", "multipart": true}, "resumable": {"path": "/resumable/upload/drive/v2/files", "multipart": true}}}, "id": "drive.files.insert", "httpMethod": "POST", "path": "files", "response": {"$ref": "File"}}, ...);

In the parameters I'm sending, there is data and mimetype:

$created = $apiService->files->insert($driveFile, array('data' => $data,'mimeType' => $mimeType));

And in the insert function, there is an array_merge with data and mimetype:

public function insert(DriveFile $postBody, $optParams = array()) {
  $params = array('postBody' => $postBody);
  $params = array_merge($params, $optParams);
  $data = $this->__call('insert', array($params));
  if ($this->useObjects()) {
    return new DriveFile($data);
  } else {
    return $data;

I don't find them in the insert part of the line I've mentionned above. Is it tied to that?

By : vicrabb


Just check out the current API Client from Google SVN. We had the same problem but after doing an svn checkout, it magically worked and thanks to Alain and Claudio for their swift response on this.

By : Muffy

This video can help you solving your question :)
By: admin