2013-04-05 20 views
0

如何在php中使用setBlobProperties來設置ContentType?下面的代碼是我通過谷歌發現的,但那個不起作用。視頻確實出現在blob存儲中,但內容類型設置爲:application/octet-stream。此外,該語言未設置爲'nl-BE',但顯示'空'。azure:使用PHP設置blob內容類型

$storageClient->putLargeBlob($_POST['container'], $_POST['filename'], $tempFile); 
$storageClient->setBlobProperties($_POST['container'], $_POST['filename'], null, array(
    'x-ms-blob-content-language' => 'nl-BE', 
    'x-ms-blob-content-type' => 'video/mp4' 
)); 

回答

2

好吧,原諒我..這段代碼的工作,但我指的是錯誤的(曾與兩個名稱相同的PHP頁面,並且我不是使用一個被編輯)。

對不起!但是現在,有人在未來尋找這個,會有這個答案:)。

3

使用新的sdk,可以如下設置內容類型(我在本例中已經設置了gif圖像的內容類型)。

$blobRestProxy = ServicesBuilder::getInstance()->createBlobService($connectionString); 
//upload 
$blob_name = "image.gif"; 
$content = fopen("image.gif", "r"); 

$options = new CreateBlobOptions(); 
$options->setBlobContentType("image/gif"); 
try { 
    //Upload blob 
    $blobRestProxy->createBlockBlob("containername", $blob_name, $content, $options); 
    echo "success"; 
} catch(ServiceException $e){ 
    $code = $e->getCode(); 
    $error_message = $e->getMessage(); 
    echo $code.": ".$error_message."<br />"; 
} 
+0

此代碼無效。它導致和錯誤。 – 2017-12-14 20:41:36