I'm guessing here that Silverlight (in your case) simply sends a POST request with the file in the request body (using chunked transfer encoding).
To handle this, create a new Poco::Net::HTTPRequestHandler subclass that you create in your request handler factory for the file upload path.
The handleRequest() method should look as follows:
- Code: Select all
void handleRequest(Poco::Net::HTTPServerRequest& request, Poco::Net::HTTPServerResponse& response)
{
// do some checks here
if (request.getMethod() == Poco::Net::HTTPRequest::HTTP_POST)
{
// copy request body containing uploaded file to a local file
Poco::FileOutputStream ostr("uploaded_file.dat");
Poco::StreamCopier::copyStream(request.stream(), ostr);
response.setStatusAndReason(Poco::Net::HTTPResponse::HTTP_OK);
response.send();
}
else
{
response.setStatusAndReason(Poco::Net::HTTPResponse::HTTP_BAD_REQUEST);
response.send();
}
}