/** * コンテナーを作成する * * IMPORTANT: * コンテナーの名前は、常に小文字にする必要があります。 * コンテナー名に大文字が含まれている場合や、コンテナーの名前付け規則の他の違反がある場合、400 エラー (無効な要求) が発生することがあります。 * コンテナーの名前付け規則については、https://msdn.microsoft.com/library/azure/dd135715.aspxをご覧ください。 * * @param type $containerName * @param type $publicAccess * @param type $metadata * @throws Exception */ public function createBlobContainer($containerName, $publicAccess = PublicAccessType::NONE, $metadata = null) { $createContainerOptions = new CreateContainerOptions(); $createContainerOptions->setPublicAccess($publicAccess); if ($metadata) { $createContainerOptions->setMetadata($metadata); } try { $this->blobRestProxy->createContainer($containerName, $createContainerOptions); } catch (Exception $e) { throw new Exception($e->getMessage(), $e->getCode()); } }
/** * @covers WindowsAzure\Blob\Models\CreateContainerOptions::getMetadata */ public function testGetMetadata() { // Setup $container = new CreateContainerOptions(); $expected = array('key1' => 'value1', 'key2' => 'value2'); $container->setMetadata($expected); // Test $actual = $container->getMetadata(); // Assert $this->assertEquals($expected, $actual); }
/** * @covers WindowsAzure\Blob\BlobRestProxy::getContainerMetadata * @covers WindowsAzure\Blob\BlobRestProxy::_getContainerPropertiesImpl */ public function testGetContainerMetadata() { // Setup $name = 'getcontainermetadata' . $this->createSuffix(); $options = new CreateContainerOptions(); $expected = array('name1' => 'MyName1', 'mymetaname' => '12345', 'values' => 'Microsoft_'); $options->setMetadata($expected); $this->createContainer($name, $options); $result = $this->restProxy->getContainerProperties($name); $expectedETag = $result->getETag(); $expectedLastModified = $result->getLastModified(); // Test $result = $this->restProxy->getContainerMetadata($name); // Assert $this->assertEquals($expectedETag, $result->getETag()); $this->assertEquals($expectedLastModified, $result->getLastModified()); $this->assertEquals($expected, $result->getMetadata()); }
public static function getInterestingCreateContainerOptions() { $ret = array(); $options = new CreateContainerOptions(); array_push($ret, $options); $options = new CreateContainerOptions(); $options->setTimeout(10); array_push($ret, $options); $options = new CreateContainerOptions(); $options->setTimeout(-10); array_push($ret, $options); $options = new CreateContainerOptions(); $options->setPublicAccess('container'); array_push($ret, $options); $options = new CreateContainerOptions(); $options->setPublicAccess('blob'); array_push($ret, $options); $options = new CreateContainerOptions(); $metadata = array('foo' => 'bar', 'boo' => 'baz'); $options->setMetadata($metadata); array_push($ret, $options); return $ret; }
/** * Update a container with some properties * * @param string $container * @param array $properties * * @throws NotFoundException * @return void */ public function updateContainerProperties($container, $properties = []) { $this->checkConnection(); $options = new CreateContainerOptions(); $options->setMetadata($properties); // $options->setPublicAccess('blob'); $this->blobConn->setContainerMetadata($container, $options); }