문제

How do I use the setBlobProperties in php to set the ContentType? The code below is what I found via google, but that one isn't working. The video does appear in the blob storage, but the content-type is set to: application/octet-stream. Also the language isn't set to 'nl-BE' but shows 'empty'.

$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'
));
도움이 되었습니까?

해결책

Ok, excuse me.. this code does work, but I was referring to the wrong one (had two php pages with the same name, and was editing in the one that i'm not using).

Sorry! But now, someone who is looking for this in the future, will have this as the answer :).

다른 팁

Using new sdk, one can set the content type as follows(i have set the content type for gif image in this example).

$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 />";
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top