Hi.
I'm trying to write class for uploading files to HTTP server. I have a one, which uses QNetworkAccessManager::post(const QNetworkRequest & request, const QByteArray & data) method, but all the time when i want to upload file - i have to load entire(!) of file content into memory (QByteArray). I decided to find a better way to do the same. I stumbled on this project:
http://code.google.com/p/datacod-qt-tools/
and in uploader.cpp file
(http://code.google.com/p/datacod-qt-...r/uploader.cpp, from line no. 85)
i found that i can do it better by creating class that inherits QIODevice and reimplementing virtual qint64 readData(char *data, qint64 maxlen) and virtual qint64 size() methods. When you want to upload file - just create instance of this class and pass it to QNetworkAccessManager::post(const QNetworkRequest & request, QIODevice * data) method. Here's prepared class:
http://code.google.com/p/datacod-qt-...er/qupfile.cpp
It seems to be a good solution and i thought that it'll work. Unfortunately - it doesn't. QUpFile::readData(char *data, qint64 maxlen) is not called even once and uploadProgress(qint64 bytesWritten, qint64 bytesTotal) signal is emitted only one time (bytesWritten = bytesTotal = 0).
Anybody have idea what's wrong with it or have another way to upload file without loading entire of its content into memory?
Thank you in advance.
Greet.
Bookmarks