annyoung

Azure blob storage SDK set Content-Type using php 본문

프로그래밍

Azure blob storage SDK set Content-Type using php

nopsled 2019. 2. 12. 17:41

Can't find some example that set blob's Content-Type from official site.


Here is example code.


<?php
require_once(__DIR__ . '/autoload.php');

use MicrosoftAzure\Storage\Blob\BlobRestProxy;
use MicrosoftAzure\Storage\Blob\Models\CreateBlockBlobOptions;

// declaration variables
$connectionString = 'INPUT_YOUR_SECRET_KEY';
$containerName = 'testContainer';
$blobName = 'blob.json';
$content = '{"nopsled":"blog"}';
$blobContentType = 'application/json; application/json; charset=UTF-8';

$blobClient = BlobRestProxy::createBlobService($this->connectionString);

$options = new CreateBlockBlobOptions();
$options->setContentType($blobContentType);
$blobClient->createBlockBlob($containerName, $blobName, json_encode($content, JSON_UNESCAPED_UNICODE), $options);
// json_encode korean language using by JSON_UNESCAPED_UNICODE





Comments