When I'm sending file to ftp server and I receive message QIODevice::read: device not open (after sent this file..)
Output looks like this:
Uploaded 1673 of 1673
QIODevice::read: device not open
Finished 0
#include "uploader.h"
Uploader::Uploader(QObject *parent) :
QObject(parent)
{
}
void Uploader::start(const QString &fileName) {
QUrl url("ftp://adresIP/test/tt.txt");
url.setUserName("ftp@domena.pl");
url.setPassword("passwd");
file = new QFile(fileName);
QByteArray putData;
file->open(QIODevice::ReadOnly);
putData.append(file->readAll());
//-- other attempts
file->flush();
file->close();
delete file;
//--
reply = nam.put(QNetworkRequest(url), putData);
connect(reply, SIGNAL(uploadProgress(qint64, qint64)), this, SLOT(uploadProgress(qint64, qint64)));
connect(reply, SIGNAL(finished()), this, SLOT(uploadDone()));
}
void Uploader::uploadProgress(qint64 bytesSent, qint64 bytesTotal) {
qDebug() << "Uploaded" << bytesSent << "of" << bytesTotal;
}
void Uploader::uploadDone() {
qDebug() << "Finished" << reply->error();
reply->deleteLater();
}
//uploader.h
QNetworkAccessManager nam;
QFile *file;
QNetworkReply *reply;
//main.cpp
Uploader u;
u.start("F:\\song.mp3");
EDIT:
I made a test on Qt 5.0.1, on Ubuntu (before it was Windows, Qt 5.3) and here it's everything OK ( message QIODevice::read: device not open
is not displayed..). It could be Qt Framework bug ?