【发布时间】:2015-07-24 11:27:14
【问题描述】:
我正在运行这段代码
require_once 'windowsazure\windowsazure.php';
use WindowsAzure\Common\ServicesBuilder;
use WindowsAzure\Blob\Models\CreateContainerOptions;
use WindowsAzure\Blob\Models\PublicAccessType;
use WindowsAzure\Common\ServiceException;
try {
$connectionString = "DefaultEndpointsProtocol=http;AccountName=xxx;AccountKey=yyyy";
// Create blob REST proxy.
$blobRestProxy = ServicesBuilder::getInstance()->createBlobService($connectionString);
$createContainerOptions = new CreateContainerOptions();
$createContainerOptions->setPublicAccess(PublicAccessType::CONTAINER_AND_BLOBS);
// Set container metadata
$createContainerOptions->addMetaData("key1", "value1");
$createContainerOptions->addMetaData("key2", "value2");
// List blobs.
$blob_list = $blobRestProxy->listBlobs("mycontainer");
$blobs = $blob_list->getBlobs();
foreach($blobs as $blob)
{
echo $blob->getName().": ".$blob->getUrl()."<br />";
}
// Create container.
$blobRestProxy->createContainer("phpcontainer", $createContainerOptions);
}
catch(ServiceException $e) {
$code = $e->getCode();
$error_message = $e->getMessage();
echo $code . ": " . $error_message . "<br/>";
}
但是会报如下错误
遇到服务异常。 400:失败:代码:400 值:其中之一 请求输入超出范围。详细信息(如果有):OutOfRangeInputOne 的请求输入超出范围。请求编号:xxxxxx 时间:2015-05-13T08:47:18.0943278Z
当谈到向 Azure 存储发送请求的第一行时
$blob_list = $blobRestProxy->listBlobs("mycontainer");
我已经通过 pear (http_request2, mail_mime, mail_mimedecode) 安装了 Azure PHP SDK 的依赖,并将它们放在默认位置 c:\php\pear\
而我使用的connectionstring应该是正确的。
我错过了什么?
谢谢
【问题讨论】:
-
您的代码究竟在哪里遇到了错误?
-
这一行 $blob_list = $blobRestProxy->listBlobs("mycontainer");
标签: php azure storage azure-blob-storage