Quantcast
Channel: WE MOVED to github.com/microsoft/cpprestsdk. This site is not monitored!
Viewing all articles
Browse latest Browse all 4845

New Post: How to download file from SkyDrive using REST API SDK? (Windows Store app, http_client)

$
0
0
Hello.
I am trying to download file from SkyDrive using web::http::client::http_client.
std::wstring fileID = std::wstring (file_id);
    
    Platform::String ^fName = Platform::String::Concat (ref new Platform::String (L"Users\\"), ref new Platform::String (file_name));

    create_task (Windows::Storage::ApplicationData::Current->TemporaryFolder->CreateFileAsync (fName, Windows::Storage::CreationCollisionOption::ReplaceExisting))
    .then ([fileID] (StorageFile ^userSave)
    {
        file_stream <unsigned char>::open_istream (userSave, std::ios_base::out)
        .then ([fileID] (basic_istream <unsigned char> fileStream)
        {
            http_client client (SkyDriveHost);
            
            std::wstring request (fileID.c_str ());
            request.append (L"/content?download=true&access_token=");
            request.append (token);

            client.request (methods::GET, request, fileStream, 1052004, L"application/octet-stream")
            .then ([fileStream] (http_response response)
            {
                fileStream.close ();
            });
        });
    });
But I always get an exception after client.request.
Please, point me what I am doing wrong.

Viewing all articles
Browse latest Browse all 4845


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>