private function insertResumable(File $file) { $convert = $file->getType() == File::TYPE_SHEET ? 'true' : 'false'; $title = $file->isOperationCreate() ? $file->getTitle() . ' (' . date('Y-m-d H:i:s') . ')' : $file->getTitle(); $url = sprintf('%s?uploadType=resumable', self::FILE_UPLOAD); $body = ['name' => $title]; if ($convert) { $body['mimeType'] = 'application/vnd.google-apps.spreadsheet'; } if ($file->getTargetFolder()) { $url .= '&addParents=' . $file->getTargetFolder(); } $response = $this->api->request($url, 'POST', ['Content-Type' => 'application/json; charset=UTF-8', 'Content-Length' => mb_strlen(serialize($body), '8bit'), 'X-Upload-Content-Type' => 'text/csv', 'X-Upload-Content-Length' => $file->getSize()], ['json' => $body]); $locationUri = $response->getHeaderLine('Location'); return $this->putFile($file, $locationUri); }