コード例 #1
0
 public function testGetResumeUri()
 {
     $this->checkToken();
     $client = $this->getClient();
     $client->addScope("https://www.googleapis.com/auth/drive");
     $service = new Google_Service_Drive($client);
     $file = new Google_Service_Drive_DriveFile();
     $file->title = 'TESTFILE-testGetResumeUri';
     $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 Google_Http_MediaFileUpload($client, $request, 'text/plain', null, true, $chunkSizeBytes);
     // request the resumable url
     $uri = $media->getResumeUri();
     $this->assertTrue(is_string($uri));
     // parse the URL
     $parts = parse_url($uri);
     $this->assertArrayHasKey('query', $parts);
     // parse the querystring
     parse_str($parts['query'], $query);
     $this->assertArrayHasKey('uploadType', $query);
     $this->assertArrayHasKey('upload_id', $query);
     $this->assertEquals('resumable', $query['uploadType']);
 }