Retrieve the filestream for a file on the server using rest webserice

Jul 1, 2014 at 10:18 AM
Just like the way we create a stream to the file using SHCreateStreamOnFile and retrieve the IStream.
I want to open a file which is on the server and retrieve the IStream associated with it (without downloading or copying the contents to a new file)
Here is the line, i am using to retrieve the IStream for a file which is presently on my hard drive.
SmartPtr<IStream> spFileStream;
hr = SHCreateStreamOnFile(Filepath, STGM_READ, &spFileStream);
I need SmartPtr<IStream> so that i can process my file.
How should i retrieve the SmartPtr<IStream> for the file which is on the server for say dropbox or google drive using rest webservices in c++?
Jul 1, 2014 at 7:45 PM

You can use the web::http::client::http_client to make HTTP requests to REST services and fetch the data.

A simple example:
        // Create a Casablanca in memory stream backed by std::vector
        streams::container_buffer<std::vector<uint8_t>> buf;

        http_request msg(methods::GET);
        // Create an output stream from the streambuf, this will hold the data received with the HTTP response. 
        // Send the HTTP GET request to fetch the data
        http_response rsp = client.request(msg).get();
        // Wait for the response data to arrive completely
        // buf.collection() vector will contain the data received as part of the HTTP response.
Casablanca does not provide interfaces to convert Casablanca streams to IStream.

I would suggest browsing through out HTTP client test cases on how to send HTTP requests and different options to receive & save the data:

Jul 10, 2014 at 3:58 AM
Thank you so much kavya, but how should retrieve the COM IStream over the
streams::container_buffer<std::vector<uint8_t>> buf;