0); blobStream.close(); 注意,上面的流不与标准的C++流式混淆。,c++,azure,azure-storage-blobs,C++,Azure,Azure Storage Blobs" /> 0); blobStream.close(); 注意,上面的流不与标准的C++流式混淆。,c++,azure,azure-storage-blobs,C++,Azure,Azure Storage Blobs" />

Azure C++;图书馆:;无效的streambuf对象“; 我试图用C++ Azure客户端库下载一个潜在的巨大Azure块BLB。它不起作用,因为我不知道如何用缓冲区大小初始化concurrency::streams::streambuf对象。我的代码如下所示: // Assume blockBlob has been created correctly. concurrency::streams::istream blobStream = blockBlob.open_read(); // I don't know how to initialize this streambuf: concurrency::streams::streambuf<uint8_t> dlStreamBuf; size_t nBytesReturned = 0, nBytesToRead = 65536; do { // This gets the exception "Invalid streambuf object": concurrency::task<size_t> returnedTask = blobStream.read(dlStreamBuf, nBytesToRead); nBytesReturned = returnedTask.get(); bytesSoFar += nBytesReturned; // Process the data in dlStreamBuf here... } while(nBytesReturned > 0); blobStream.close(); //假设blockBlob已正确创建。 并发::流::istream blobStream=blockBlob.open_read(); //我不知道如何初始化此streambuf: 并发::流::streambuf dlStreamBuf; 大小nbytesreturn=0,nBytesToRead=65536; 做{ //这将获取异常“无效的streambuf对象”: 并发::任务返回任务=blobStream.read(dlStreamBuf,nBytesToRead); nBytesReturned=returnedTask.get(); bytesSoFar+=N字节返回; //在此处处理dlStreamBuf中的数据。。。 }而(nbytesreturn>0); blobStream.close(); 注意,上面的流不与标准的C++流式混淆。

Azure C++;图书馆:;无效的streambuf对象“; 我试图用C++ Azure客户端库下载一个潜在的巨大Azure块BLB。它不起作用,因为我不知道如何用缓冲区大小初始化concurrency::streams::streambuf对象。我的代码如下所示: // Assume blockBlob has been created correctly. concurrency::streams::istream blobStream = blockBlob.open_read(); // I don't know how to initialize this streambuf: concurrency::streams::streambuf<uint8_t> dlStreamBuf; size_t nBytesReturned = 0, nBytesToRead = 65536; do { // This gets the exception "Invalid streambuf object": concurrency::task<size_t> returnedTask = blobStream.read(dlStreamBuf, nBytesToRead); nBytesReturned = returnedTask.get(); bytesSoFar += nBytesReturned; // Process the data in dlStreamBuf here... } while(nBytesReturned > 0); blobStream.close(); //假设blockBlob已正确创建。 并发::流::istream blobStream=blockBlob.open_read(); //我不知道如何初始化此streambuf: 并发::流::streambuf dlStreamBuf; 大小nbytesreturn=0,nBytesToRead=65536; 做{ //这将获取异常“无效的streambuf对象”: 并发::任务返回任务=blobStream.read(dlStreamBuf,nBytesToRead); nBytesReturned=returnedTask.get(); bytesSoFar+=N字节返回; //在此处处理dlStreamBuf中的数据。。。 }而(nbytesreturn>0); blobStream.close(); 注意,上面的流不与标准的C++流式混淆。,c++,azure,azure-storage-blobs,C++,Azure,Azure Storage Blobs,有人能就如何正确构造和初始化concurrency::streams::streambuf向我提供建议吗 谢谢。< P>我没有使用C++的流方法,但是C++文件中提到了下载文件或蒸汽>强> >/St>两种方式。 下载到\u流方法例如: // Retrieve storage account from connection string. azure::storage::cloud_storage_account storage_account = azure::storage::clou

有人能就如何正确构造和初始化concurrency::streams::streambuf向我提供建议吗


谢谢。

< P>我没有使用C++的流方法,但是C++文件中提到了下载文件或蒸汽>强> >/St>

两种方式。 下载到\u流方法例如:

    // Retrieve storage account from connection string.
azure::storage::cloud_storage_account storage_account = azure::storage::cloud_storage_account::parse(storage_connection_string);

// Create the blob client.
azure::storage::cloud_blob_client blob_client = storage_account.create_cloud_blob_client();

// Retrieve a reference to a previously created container.
azure::storage::cloud_blob_container container = blob_client.get_container_reference(U("my-sample-container"));

// Retrieve reference to a blob named "my-blob-1".
azure::storage::cloud_block_blob blockBlob = container.get_block_blob_reference(U("my-blob-1"));

// Save blob contents to a file.
concurrency::streams::container_buffer<std::vector<uint8_t>> buffer;
concurrency::streams::ostream output_stream(buffer);
blockBlob.download_to_stream(output_stream);

std::ofstream outfile("DownloadBlobFile.txt", std::ofstream::binary);
std::vector<unsigned char>& data = buffer.collection();

outfile.write((char *)&data[0], buffer.size());
outfile.close();  

streambuf似乎是一个模板类。请尝试以下方法:

    concurrency::streams::container_buffer<std::vector<uint8_t>> output_buffer;
    size_t nBytesReturned = 0, nBytesToRead = 65536;
    do {
        // This gets the exception "Invalid streambuf object": 
        concurrency::task<size_t> returnedTask = stream.read(output_buffer, nBytesToRead);
        nBytesReturned = returnedTask.get();
        bytesSoFar += nBytesReturned;
        // Process the data in dlStreamBuf here...
    } while (nBytesReturned > 0);
    stream.close();
concurrency::streams::container\u buffer output\u buffer;
大小nbytesreturn=0,nBytesToRead=65536;
做{
//这将获取异常“无效的streambuf对象”:
并发::task returnedTask=stream.read(输出缓冲区,nBytesToRead);
nBytesReturned=returnedTask.get();
bytesSoFar+=N字节返回;
//在此处处理dlStreamBuf中的数据。。。
}而(nbytesreturn>0);
stream.close();

示例代码如下:

谢谢,但我希望有一个逐缓冲区的“读取”类型接口,以匹配当前应用程序的工作方式。还在研究……谢谢,@sguler!这确实可以编译。现在,我正试图找出如何将输出缓冲区中的数据放入实际缓冲区(无符号字符数组)。。。
    concurrency::streams::container_buffer<std::vector<uint8_t>> output_buffer;
    size_t nBytesReturned = 0, nBytesToRead = 65536;
    do {
        // This gets the exception "Invalid streambuf object": 
        concurrency::task<size_t> returnedTask = stream.read(output_buffer, nBytesToRead);
        nBytesReturned = returnedTask.get();
        bytesSoFar += nBytesReturned;
        // Process the data in dlStreamBuf here...
    } while (nBytesReturned > 0);
    stream.close();