php - 使用 Azure 存储 PHP SDK 时为 "One of the request inputs is out of range"

标签 php azure storage azure-blob-storage

我正在运行此代码

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/>";
}

但是会报如下错误

ServiceException encountered. 400: Fail: Code: 400 Value: One of the request inputs is out of range. details (if any): OutOfRangeInputOne of the request inputs is out of range. RequestId:xxxxxx Time:2015-05-13T08:47:18.0943278Z

当到达向 Azure 存储发送请求的第一行时

$blob_list = $blobRestProxy->listBlobs("mycontainer");

我已经通过 pear 安装了 Azure PHP SDK 的依赖项(http_request2、mail_mimemail_mimedecode)并将它们放在默认位置 c:\php\梨\

我使用的connectionstring应该是正确的。

我错过了什么?

谢谢

最佳答案

事实证明,我在此处屏蔽的连接字符串中错误地指定了非法帐户名称,更具体地说,我在帐户名称中使用了大写字母,但实际上 Azure 容器名称不允许包含大写字母,并且我的PHP项目还没有添加大写转小写的转换方法...

无论如何,希望遇到类似问题的人可以先检查帐户名称、容器名称和 blob 名称。

谢谢

关于php - 使用 Azure 存储 PHP SDK 时为 "One of the request inputs is out of range",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30210358/

相关文章:

azure - 使用证书获取 token 时,未将对象引用设置为对象的实例

linux - 恢复已清除的文件内容

C++/CX - GetFileAsync 抛出断点错误

php - 使用 PHP、CodeIgniter 和 MySQL 显示查询的日期字段问题?

如果需要很长时间才能返回,php ajax 调用不会返回任何内容

mysql - 无法远程连接到MySQL服务器

azure - ListBlobsSegmentedAsync 突然停止返回 Blob 目录中的文件,即使存储资源管理器显示文件在那里

c# - 存储和检索应用程序设置的正确方法是什么?

php - 如何在没有 javascript 处理的情况下使用多插入内部函数 PDO PHP 显示成功

php - 身份不明的 PHP 和 PDO 执行时间较长