Overview
Features
Download
Documentation
Community
Add-Ons & Services

Upload large files using Poco HTTPS - PUT

A general discussion forum.

Upload large files using Poco HTTPS - PUT

Postby bsriram » 17 Feb 2010, 08:53

I am new to Poco and we have been advised by architecture team to look into Poco as HTTPS client to upload files to remote server. There is a webserver running in the remote server and we need to upload files to specific directory in the remote server.
Requirement is to upload a Large file ( 3-5 GB) files. Also, we have instructed to use "HTTPS PUT" method for uploading the files.
I would like to know, whether it is feasible to upload a large files using Poco (HTTPS PUT) and any sample code to upload files use Poco would be helpful.

I apprecaite your help.

Thanks
Sriram
bsriram
 
Posts: 2
Joined: 17 Feb 2010, 08:45

Re: Upload large files using Poco HTTPS - PUT

Postby guenter » 17 Feb 2010, 12:25

Here's a small code fragment that should give you a basic idea how to do it. You'll need to wrap this code in an Application class or otherwise set up the OpenSSL machinery. See the samples in NetSSL_OpenSSL/samples.

Code: Select all
URI uri("http://localhost/upload");
Poco::File f("file.dat");
Poco::FileInputStream istr(f.path());
std::string path(uri.getPathAndQuery());
if (path.empty()) path = "/";
HTTPSClientSession session(uri.getHost(), uri.getPort());
HTTPRequest req(HTTPRequest::HTTP_PUT, path, HTTPMessage::HTTP_1_1);
req.setContentType("application/octet-stream");
req.setContentLength(f.getSize());
std::ostream& ostr = session.sendRequest(req);
StreamCopier::copyStream(istr, ostr);
HTTPResponse res;
session.receiveResponse(res);
std::cout << res.getStatus() << " " << res.getReason() << std::endl;
guenter
 
Posts: 1107
Joined: 11 Jul 2006, 16:27
Location: Austria

Re: Upload large files using Poco HTTPS - PUT

Postby bsriram » 17 Feb 2010, 13:16

Thanks for the quick response. I will try it out and get back to you.

Thanks
Sriram
bsriram
 
Posts: 2
Joined: 17 Feb 2010, 08:45


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 2 guests

cron