0

I am using code from the link https://msdn.microsoft.com/en-us/library/jj950081.aspx for uploading file anf getting response as 501 not implemented.

// Upload a file to an HTTP server.
    pplx::task<void> UploadFileToHttpServerAsync()
        {
            using concurrency::streams::file_stream;
            using concurrency::streams::basic_istream;

    return file_stream<unsigned char>::open_istream(L"myfile.txt").then([](pplx::task<basic_istream<unsigned char>> previousTask)
    {
        try
        {
            auto fileStream = previousTask.get();

            // Make HTTP request with the file stream as the body.
            http_client client(L"http://www.fourthcoffee.com");
            return client.request(methods::PUT, L"myfile", fileStream).then([fileStream](pplx::task<http_response> previousTask)
            {
                fileStream.close();

                std::wostringstream ss;
                try
                {
                    auto response = previousTask.get();
                    ss << L"Server returned returned status code " << response.status_code() << L"." << std::endl;
                }

                std::wcout << ss.str();
            });
        }
    });
}
user3168064
  • 97
  • 2
  • 11

0 Answers0