3

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 ?

Community
  • 1
  • 1
Michael M
  • 41
  • 4
  • possible duplicate of [File Upload Error With QNetworkAccessManager](http://stackoverflow.com/questions/16877363/file-upload-error-with-qnetworkaccessmanager) – hyde Aug 25 '14 at 20:52
  • But I can upload data to server.. I don't know why I got message 'QIODevice::read: device not open' always, although file was uploaded finished success ; screen: http://oi61.tinypic.com/x45cvo.jpg – Michael M Aug 25 '14 at 21:22

1 Answers1

1

I think it is a qt problem. I had the same warning after ftp uploads wirh qt 5.3 win vs2010. after installing 5.5 the message was gone.

Hannes B
  • 11
  • 1