1
我想上傳一個大文件到我的http服務器。Http上傳與進展信息,在C + +(波科/助推器)
我需要顯示上傳進度。
我怎樣才能在上傳過程中發送多少字節?
需要將事件發送到我的GUI。
在poco中,我不知道在哪裏放回調。
_session.sendRequest(_request)
_session.receiveResponse(_response)
任何想法?或鏈接,謝謝!
我想上傳一個大文件到我的http服務器。Http上傳與進展信息,在C + +(波科/助推器)
我需要顯示上傳進度。
我怎樣才能在上傳過程中發送多少字節?
需要將事件發送到我的GUI。
在poco中,我不知道在哪裏放回調。
_session.sendRequest(_request)
_session.receiveResponse(_response)
任何想法?或鏈接,謝謝!
這是08年的「部分」討論。諷刺的是,我正在尋找完全相同的東西。
http://sourceforge.net/mailarchive/message.php?msg_id=20619477
編輯:12年2月14日
這是不是最好的,但它的作品...可能會最好的一次寫1K塊。 我想看看你的建議。
std::string szMessage;
.... /* fill your szMessage such as with a Form.write() */ ..
CountingOutputStream _cos(_session.sendRequest(_request))
std::streamsize len = 0;
string::iterator it;
for (it=szMessage.begin() ; it < szMessage.end(); it++) {
len ++;
_cos.put(*it);
if(len %4096 ==0)
cout << "len: " << len << endl;
}
cout << "Chars printed: " << len << endl;
std::istream& rsout = _session.receiveResponse(_response)
std::ostringstream ostr;
StreamCopier::copyStream(rsout, ostr);
// Retrieve response is not necessary if we have the resp code
std::cout << endl; response.write(cout);
std::cout << ostr.str();
int code = response.getStatus();
if (code != nRespCode) {
stringstream s;
s << "HTTP Error(*): " << code;
throw Poco::IOException(s.str());
}
這還不是很清楚。 – iuwei 2012-02-14 02:47:13
我覺得這不是很優雅。但它的工作。我會把它放在我的編輯中。謝謝! – iuwei 2012-02-14 03:21:36
我將char buff [HALF_MB]作爲緩衝區,並使用content-length或file-size來控制最後一個塊:) – iuwei 2012-02-20 09:57:40