gpt4 book ai didi

rest - 尝试写入页 blob 失败,并显示“错误 : The value for one of the HTTP headers is not in the correct format

转载 作者:行者123 更新时间:2023-12-02 23:45:17 25 4
gpt4 key购买 nike

我尝试使用 azure-storage-cpp 的 API 通过以下代码写入页面 blob:

// The code is representative. I have removed some of the error handling code.
void page_blobs_async()
{

// Initialize storage account
azure::storage::cloud_storage_account storage_account = azure::storage::cloud_storage_account::parse(storage_connection_string);

// Create a blob container
azure::storage::cloud_blob_client blob_client = storage_account.create_cloud_blob_client();
azure::storage::cloud_blob_container container = blob_client.get_container_reference(_XPLATSTR("my-sample-page-async-container"));

// Return value is true if the container did not exist and was successfully created.
container.create_if_not_exists();

// Make the blob container publicly accessible
azure::storage::blob_container_permissions permissions;
permissions.set_public_access(azure::storage::blob_container_public_access_type::blob);
container.upload_permissions(permissions);
filename = "DataFile1.txt" // This contains '1'
string blob_name = "async_blob"
concurrency::streams::istream input_stream = concurrency::streams::file_stream<uint8_t>::open_istream(_XPLATSTR(filename)).get();
azure::storage::cloud_block_blob blob1 = container.get_block_blob_reference(_XPLATSTR(blob_name));
azure::storage::cloud_page_blob blob1 = container.get_page_blob_reference(_XPLATSTR(blob_name));
blob1.create(16 * 1024 * 1024);
std::cout<<"Blob write started"<<std::endl;
blob1.upload_from_stream(input_stream);

}

我收到以下错误:

错误:HTTP header 之一的值格式不正确。HTTP header 之一的值格式不正确。请求 ID:e4fe5ee9-e01e-0045-6076-386b87000000时间:2018-08-20T11:08:57.8352526Z

header 转储:

headers Date:Mon, 20 Aug 2018 11:08:57 GMT
headers ETag:"0x8D6068BAC4DC466"
headers Last-Modified:Mon, 20 Aug 2018 10:57:08 GMT
headers Server:Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
headers Transfer-Encoding:chunked
headers x-ms-blob-public-access:blob
headers x-ms-lease-state:available
headers x-ms-lease-status:unlocked
headers x-ms-request-id:e4fe5ebd-e01e-0045-3a76-386b87000000
headers x-ms-version:2017-04-17
headers Date:Mon, 20 Aug 2018 11:08:57 GMT
headers ETag:"0x8D6068D535B837D"
headers Last-Modified:Mon, 20 Aug 2018 11:08:57 GMT
headers Server:Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
headers Transfer-Encoding:chunked
headers x-ms-request-id:e4fe5ec5-e01e-0045-4076-386b87000000
headers x-ms-version:2017-04-17
headers Date:Mon, 20 Aug 2018 11:08:57 GMT
headers ETag:"0x8D6068D535DE4B5"
headers Last-Modified:Mon, 20 Aug 2018 11:08:57 GMT
headers Server:Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
headers Transfer-Encoding:chunked
headers x-ms-request-id:e4fe5ee4-e01e-0045-5b76-386b87000000
headers x-ms-request-server-encrypted:true
headers x-ms-version:2017-04-17
Blob write started
headers Content-Length:331
headers Content-Type:application/xml
headers Date:Mon, 20 Aug 2018 11:08:57 GMT
headers Server:Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
headers x-ms-request-id:e4fe5ee9-e01e-0045-6076-386b87000000
headers x-ms-version:2017-04-17
headers Content-Length:331
headers Content-Type:application/xml
headers Date:Mon, 20 Aug 2018 11:08:57 GMT
headers Server:Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
headers x-ms-request-id:e4fe5ee9-e01e-0045-6076-386b87000000
headers x-ms-version:2017-04-17

我正在使用 cpprestsdk-2.9.1 和 Ubuntu 16.04。

最佳答案

如果您使用 Fiddler 等工具捕获请求流量,您可能会看到错误消息指向 header x-ms-blob-content-length

参见Storage page blob REST API :

The page blob size must be aligned to a 512-byte boundary.

这是设计使然,并在storage docs中进行了描述。 :

Page blobs are a collection of 512-byte pages optimized for random read and write operations.

所以我们应该保证上传的文件长度是512字节的倍数。另外,upload_from_stream是初始化一个新的page blob(覆盖现有的),提前create似乎没有必要。

关于rest - 尝试写入页 blob 失败,并显示“错误 : The value for one of the HTTP headers is not in the correct format,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51941427/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com