private function expectFilenameTranslation($filename, $blob_key)
 {
     $req = new \google\appengine\CreateEncodedGoogleStorageKeyRequest();
     $req->setFilename($filename);
     $resp = new \google\appengine\CreateEncodedGoogleStorageKeyResponse();
     $resp->setBlobKey($blob_key);
     $this->apiProxyMock->expectCall('blobstore', 'CreateEncodedGoogleStorageKey', $req, $resp);
 }
예제 #2
0
 public function testServeRangeHeaderSuccess()
 {
     $req = new \google\appengine\CreateEncodedGoogleStorageKeyRequest();
     $req->setFilename("/gs/some_bucket/some_object");
     $resp = new \google\appengine\CreateEncodedGoogleStorageKeyResponse();
     $resp->setBlobKey("some_blob_key");
     $this->apiProxyMock->expectCall("blobstore", "CreateEncodedGoogleStorageKey", $req, $resp);
     $filename = "gcs://some_bucket/some_object";
     $expected_headers = ["X-AppEngine-BlobKey" => "some_blob_key", "X-AppEngine-BlobRange" => "bytes=100-200", "Content-Disposition" => "attachment; filename=foo.jpg", "Content-Type" => "image/jpeg"];
     $options = ["save_as" => "foo.jpg", "use_range" => true, "content_type" => "image/jpeg"];
     $_SERVER["HTTP_RANGE"] = "bytes=100-200";
     BlobstoreService::serve($filename, $options);
     $this->assertEquals(ksort($this->sent_headers), ksort($expected_headers));
     $this->apiProxyMock->verify();
 }