使用Azure存储PHP SDK时,“其中一个请求输入超出范围”

时间:2022-01-04 16:49:26

I am running this code

我正在运行此代码

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

However, it will report the following error

但是,它将报告以下错误

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

遇到ServiceException。 400:失败:代码:400值:其中一个请求输入超出范围。详细信息(如果有):请求输入的OutOfRangeInputOne超出范围。 RequestId:xxxxxx时间:2015-05-13T08:47:18.0943278Z

when it came to the first line of sending request to Azure storage

当涉及向Azure存储发送请求的第一行时

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

I've installed the dependency of Azure PHP SDK via pear (http_request2, mail_mime, mail_mimedecode) and put them at default position c:\php\pear\

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

And the connectionstring I used should be a correct one.

我使用的连接字符串应该是正确的。

What I have missed?

我错过了什么?

Thanks

2 个解决方案

#1


It turns out that I wrongly specify an illegal account name in the connection string that I masked here, to be more specific, I use upper case in the account name but actually Azure container name is not allowed to contain Upper case, and my PHP project has not added the upper case to lower case transformation method...

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

Anyway, hoping anyone who has confronted similar problems may check the account name, container name and blob name firstly.

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

Thanks

#2


https://Your_blob_url.blob.core.windows.net/containerImage2-f110ea8t-5ada-42f2-8f64-2614c9c45df0 I was passing like this to the url, where i am not separating the container then I changed to https://Your_blob_url.blob.core.windows.net/container/Image2-f110ea8t-5ada-42f2-8f64-2614c9c45df0 and it worked for me...

https://Your_blob_url.blob.core.windows.net/containerImage2-f110ea8t-5ada-42f2-8f64-2614c9c45df0我这样传递到url,我没有分隔容器然后我改为https:// Your_blob_url .blob.core.windows.net / container / Image2-f110ea8t-5ada-42f2-8f64-2614c9c45df0它对我有用...

#1


It turns out that I wrongly specify an illegal account name in the connection string that I masked here, to be more specific, I use upper case in the account name but actually Azure container name is not allowed to contain Upper case, and my PHP project has not added the upper case to lower case transformation method...

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

Anyway, hoping anyone who has confronted similar problems may check the account name, container name and blob name firstly.

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

Thanks

#2


https://Your_blob_url.blob.core.windows.net/containerImage2-f110ea8t-5ada-42f2-8f64-2614c9c45df0 I was passing like this to the url, where i am not separating the container then I changed to https://Your_blob_url.blob.core.windows.net/container/Image2-f110ea8t-5ada-42f2-8f64-2614c9c45df0 and it worked for me...

https://Your_blob_url.blob.core.windows.net/containerImage2-f110ea8t-5ada-42f2-8f64-2614c9c45df0我这样传递到url,我没有分隔容器然后我改为https:// Your_blob_url .blob.core.windows.net / container / Image2-f110ea8t-5ada-42f2-8f64-2614c9c45df0它对我有用...