PDA

View Full Version : QFtp Resume Upload



Goldmmbr
12th October 2009, 15:25
Hi, i need to implement a ftp client that has a resume upload feature using QFtp.

I have tried implementing the resume function using raw commands ... something like the following:



ftp->rawCommand("TYPE I");
ftp->rawCommand("PASV");
ftp->rawCommand("REST" + x); //where x is the string with the position ...
ftp->rawCommand("STOR" + remoteFileName);


however i am getting the following error:

425 :: "Can't open data connection."

I have looked over the QFtp sourcefile and i saw that the ftp data channel isn't opened when using raw commands.
I have tried opening a data channel using a QTcpSocket like this :



void FtpClass::onRawCmdReply(int replyCode, const QString & detail )
{
qDebug() << replyCode << " :: " << detail;

if (replyCode == 227) // detail = Entering Passive Mode (a1,a2,a3,a4,p1,p2)
// host = a1.a2.a3.a4
// port = p1*256 + p2
{
QRegExp addrPortPattern(QLatin1String("(\\d+),(\\d+),(\\d+),(\\d+),(\\d+),(\\d+)"));
if (addrPortPattern.indexIn(detail) == -1)
{
{
qDebug("QFtp: bad 227 response -- address and port information missing");
}
}
else
{
_dataSocket = new QTcpSocket(this);
QStringList lst = addrPortPattern.capturedTexts();
QString host = lst[1] + QLatin1Char('.') + lst[2] + QLatin1Char('.') + lst[3] + QLatin1Char('.') + lst[4];
quint16 port = (lst[5].toUInt() << 8) + lst[6].toUInt();
_dataSocket->connectToHost(host, port);
if (!_dataSocket->waitForConnected(1000))
{
qDebug() << "cannot connect to: " << host << "port :" << port;
}
else
{
qDebug() << "connected to: " << host << "port :" << port;
}
}
}
}



But if i do that i get the following error :

426 :: "Connection closed; transfer aborted."

It is not a server issue since i've tested using a random ftp client and the server supports resuming.
Also it is not a firewall issue since i dissabled the firewalls on both machines.

What am i doing wrong ? can someone help me please?

Sahab
26th January 2010, 10:31
no one suggestion??((