Overview
Features
Download
Documentation
Community
Add-Ons & Services

HTTP File Upload question

Please post support and help requests here.

HTTP File Upload question

Postby badreddine » 12 Jul 2008, 22:05

Hello All,
I'm using POCO to implement HTTP Upload file to URI, I use HTTPClientSession and l_HTTPReq with the method HTTP_PUT, but this does not work, i have a "Bad request response"
can you help me please with a sample code, especially how to set content of a file to URI, I want also to implement this for compressed files, tha means, setting zip file to URI,

thanks a lot for support
badreddine
 
Posts: 4
Joined: 15 Jun 2008, 14:16

Re: HTTP File Upload question

Postby alex » 13 Jul 2008, 15:44

I'm using POCO to implement HTTP Upload file to URI, I use HTTPClientSession and l_HTTPReq with the method HTTP_PUT, but this does not work, i have a "Bad request response"

If you do not have control over what the server allows, then you probably won't be able to do that.

can you help me please with a sample code, especially how to set content of a file to URI, I want also to implement this for compressed files, tha means, setting zip file to URI
Code: Select all

HTTPClientSession s("localhost", port);
HTTPRequest request(HTTPRequest::HTTP_POST, "/echo");
std::string body;
// fill the string with file contents here
request.setContentLength((int) body.length());
s.sendRequest(request) << body;


Of course, in the above example, you have to fill the string being
sent with the file contents (see this post on how to do that) and provide appropriate HTTP server parameters to the
HTTPClientSession and HTTPRequest.

If you are looking for file compressing facilities in POCO, those do exist and work, but are still in the sandbox.

Alex
alex
 
Posts: 1130
Joined: 11 Jul 2006, 16:27
Location: United_States


Return to Support

Who is online

Users browsing this forum: beetie and 5 guests