سؤال

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