azure:使用PHP设置blob内容类型
如何使用php中的setBlobProperties设置ContentType?下面的代码是我通过谷歌找到的,但是这个代码不起作用。视频确实显示在blob存储器中,但内容类型设置为:application/octet stream。此外,该语言未设置为“nl BE”,但显示为“空”azure:使用PHP设置blob内容类型,php,azure,blob,contenttype,Php,Azure,Blob,Contenttype,如何使用php中的setBlobProperties设置ContentType?下面的代码是我通过谷歌找到的,但是这个代码不起作用。视频确实显示在blob存储器中,但内容类型设置为:application/octet stream。此外,该语言未设置为“nl BE”,但显示为“空” $storageClient->putLargeBlob($_POST['container'], $_POST['filename'], $tempFile); $storageClient->setB
$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'
));
好的,对不起。。这段代码确实有效,但我指的是错误的代码(有两个同名的php页面,在我不使用的页面中进行编辑)
对不起!但是现在,将来寻找这个的人,会得到这个答案:)。好的,对不起。。这段代码确实有效,但我指的是错误的代码(有两个同名的php页面,在我不使用的页面中进行编辑)
对不起!但是现在,将来寻找这一点的人将得到以下答案:)。使用新的sdk,可以如下设置内容类型(我在本例中为gif图像设置了内容类型)
$blobRestProxy=ServicesBuilder::getInstance()->createBlobService($connectionString);
//上传
$blob_name=“image.gif”;
$content=fopen(“image.gif”、“r”);
$options=新建CreateBlobOptions();
$options->setBlobContentType(“图像/gif”);
试一试{
//上传blob
$blobRestProxy->createBlockBlob(“containername”、$blob_name、$content、$options);
呼应“成功”;
}捕获(ServiceException$e){
$code=$e->getCode();
$error_message=$e->getMessage();
echo$code.“:”$error_message.“
”;
}
使用新的sdk,可以如下设置内容类型(在本例中,我已经为gif图像设置了内容类型)
$blobRestProxy=ServicesBuilder::getInstance()->createBlobService($connectionString);
//上传
$blob_name=“image.gif”;
$content=fopen(“image.gif”、“r”);
$options=新建CreateBlobOptions();
$options->setBlobContentType(“图像/gif”);
试一试{
//上传blob
$blobRestProxy->createBlockBlob(“containername”、$blob_name、$content、$options);
呼应“成功”;
}捕获(ServiceException$e){
$code=$e->getCode();
$error_message=$e->getMessage();
echo$code.“:”$error_message.“
”;
}
$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 />";
}