public function testResultCode() { $client = $this->getClient(); $request = new Postman_Google_Http_Request('http://www.example.com', 'POST'); // Test resumable upload $media = new Postman_Google_Http_MediaFileUpload($client, $request, 'image/png', 'a', true); $this->assertEquals(null, $media->getHttpResultCode()); }
} else { $authUrl = $client->createAuthUrl(); } /************************************************ If we're signed in then lets try to upload our file. ************************************************/ if ($client->getAccessToken()) { $file = new Postman_Google_Service_Drive_DriveFile(); $file->title = "Big File"; $chunkSizeBytes = 1 * 1024 * 1024; // Call the API with the media upload, defer so it doesn't immediately return. $client->setDefer(true); $request = $service->files->insert($file); // Create a media file upload to represent our upload process. $media = new Postman_Google_Http_MediaFileUpload($client, $request, 'text/plain', null, true, $chunkSizeBytes); $media->setFileSize(filesize(TESTFILE)); // Upload the various chunks. $status will be false until the process is // complete. $status = false; $handle = fopen(TESTFILE, "rb"); while (!$status && !feof($handle)) { $chunk = fread($handle, $chunkSizeBytes); $status = $media->nextChunk($chunk); } // The final value of $status will be the data from the API for the object // that has been uploaded. $result = false; if ($status != false) { $result = $status; }