-
Notifications
You must be signed in to change notification settings - Fork 0
/
11_azure_blob_container.php
44 lines (33 loc) · 1.28 KB
/
11_azure_blob_container.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
require_once 'vendor\autoload.php';
use WindowsAzure\Common\ServicesBuilder;
use WindowsAzure\Blob\Models\CreateContainerOptions;
use WindowsAzure\Blob\Models\PublicAccessType;
use WindowsAzure\Common\ServiceException;
// https://azure.microsoft.com/en-us/documentation/articles/storage-php-how-to-use-blobs/
// Storage의 connection string 제공
$connectionString = "DefaultEndpointsProtocol=http;AccountName=xecondemo01;AccountKey=<어카운트키>";
// REST proxy 생성
$blobRestProxy = ServicesBuilder::getInstance()->createBlobService($connectionString);
$createContainerOptions = new CreateContainerOptions();
//setPublicAccess 접근 정책 설정
// CONTAINER_AND_BLOBS:
// 전체 엑세스 권한
//
// BLOBS_ONLY:
// blob들에 대해서만 읽기 권한.
$createContainerOptions->setPublicAccess(PublicAccessType::CONTAINER_AND_BLOBS);
// 컨테이너 메타데이터 설정
$createContainerOptions->addMetaData("XECON", "XpressEngine");
$createContainerOptions->addMetaData("Azure", "Cloud");
try {
// 컨테이너 생성
$blobRestProxy->createContainer("xecondevcontainer", $createContainerOptions);
}
catch(ServiceException $e){
// 에러 핸들링
$code = $e->getCode();
$error_message = $e->getMessage();
echo $code.": ".$error_message."<br />";
}
?>