我已经建立了一个Windows Azure的网站(PHP),我想连接到Azure存储(BLOB)环境。我走过How to use the Blob service from PHP教程,但只提到当网站存储在本地时的情况。连接到通过Azure的网站蔚斑点用PHP
我试图设置几个案例,但我不断得到一个http 500错误。
<?php
require_once 'WindowsAzure/WindowsAzure.php';
use WindowsAzure\Common\ServicesBuilder;
use WindowsAzure\Common\ServiceException;
//$connectionString = "\WindowsAzure\Blob\Internal\IBlob";
// Create blob REST proxy.
$blobRestProxy = ServicesBuilder::getInstance()->createBlobService($connectionString); // the code gets stuck at this line, result is a HTTP 500 error
$content = fopen("C:\Users\Public\Pictures\Sample%20Pictures\Woestijn.jpg", "r");
$blob_name = "newBlob";
try {
//Upload blob
$blobRestProxy->createBlockBlob("default", $blob_name, $content);
}
catch(ServiceException $e){
// Handle exception based on error codes and messages.
// Error codes and messages are here:
// http://msdn.microsoft.com/en-us/library/windowsazure/dd179439.aspx
$code = $e->getCode();
$error_message = $e->getMessage();
echo $code.": ".$error_message."<br />";
}?>
有没有人有类似的问题,并设法弄清楚?
编辑:
我现在缩小了错误搜索范围。我进入ServicesBuilder.php文件,并逐行注释掉,直到页面停止工作。出了问题,在该生产线是$ HttpClient的,如下图所示:
public function createBlobService($connectionString)
{
$settings = StorageServiceSettings::createFromConnectionString(
$connectionString
);
$httpClient = $this->httpClient();
$serializer = $this->serializer();
$uri = Utilities::tryAddUrlScheme(
$settings->getBlobEndpointUri()
);
你不”您需要在您的文章中加入签名 - 您的用户卡会自动添加。阅读[常见问题](http://stackoverflow.com/faq#signatures)了解更多详情。 – Artemix
为什么你的'$ connectionString'变量被注释掉了?另外,请查看Sandrino的建议。 – astaykov
connectionString被注释掉,因为我在那里做了没有工作:)。 connectionString Sandrino建议看起来像我需要的,但仍然无法正常工作。 – Jeroen