i am using QT software in solaris,
i opened remote system through QFtp methods i.e.. connectToHost()
after that, loged in through login().
now my problem is, i am trying to get data from remote system, through
int get ( const QString & file, QIODevice * dev = 0 )

at first argument i am giving "file name" to download from remote sys., where should i store downloaded file in local system , why we are using QIODevice, how to use QIODevice in get fuction

Dani AI

Generated

Quick practical follow‑up (answers for resume, size and alternatives) that builds on ’s posts and ’s pointers.

  • Get remote file size: request a directory listing and read the file entry’s size from the QUrlInfo delivered by QFtp’s list/listInfo sequence. That gives a reliable file size to compare with your local partial file. (tool.oschina.net)

  • Typical resume workflow (tested pattern)

    1. Stat the local file (QFile::size()).
    2. Open the local file for appending.
    3. Send the FTP REST command with the local size as the restart offset. QFtp exposes rawCommand() so you can send REST and then proceed. Wait for the server’s 350 reply before starting the transfer. (ftp.nmr.mgh.harvard.edu)

    Minimal sketch (adapt to Qt3 signal/slot style):

    qint64 offset = localFile.exists() ? localFile.size() : 0;
    localFile.open(QIODevice::WriteOnly | QIODevice::Append);
    ftp->rawCommand(QString("REST %1").arg(offset));
    // on rawCommandReply(int code, const QString &detail) { if (code==350) ftp->get(remotePath, &localFile); }

    The REST reply must be checked (350). If the server accepts it, follow with RETR (QFtp::get) or a raw RETR; then the server will resume the transfer from that offset. (ftp.nmr.mgh.harvard.edu)

  • Caveats and troubleshooting

    • Servers must support SIZE/REST; you can also send a raw SIZE command or parse listInfo. Verify replies and use dataTransferProgress to track progress. (datatracker.ietf.org)
    • QFtp mixes a high‑level command queue with raw commands; that can be fragile on some stacks (avoid blind mixing or test carefully). If you see inconsistent behavior, try sending REST and RETR as raw commands and handle reads explicitly. (manpages.org)
  • Alternatives

    • For a production, robust resume use libcurl (CURLOPT_RESUME_FROM) or move to Qt5+ APIs (QNetworkAccessManager or the QtFtp compatibility add‑on) rather than fighting low‑level FTP quirks. libcurl is battle‑tested for resume/large files. (manpages.opensuse.org)

Notes: check passive/active mode and TYPE (binary) before resume, always flush/close the local file on error, and confirm the server’s reply codes during testing.

Recommended Answers

All 7 Replies

QIODevice is a base class for basically anything in Qt that can be considered a read/write device, such as QFile.

In the function call

int get ( const QString & file, QIODevice * dev = 0 )

-QString reference file is the source on the server
-QIODevice pointer variable dev is the local destination for storage. Purpose of QIODevice in the parameter is that the file can be also stored in other formats than QFile.

You can provide a QFile pointer, QBuffer pointer or a socket pointer as dev. If dev is 0, then the readyRead() signal is emitted when there is data available to read. You can connect this signal to a slot and catch the file somewhere in your code.

can i use my home path i.e.. /homae/user as QIODevice for storing file to local system

can i use my home path i.e.. /homae/user as QIODevice for storing file to local system

Yes and no. First you need to make a QFile, set current directory to /home/user with QDir and then provide the file to QFtp::get

1)now i am able to download file, but problem is, After downloading some bytes of data i am closing application and starting again then at that time it is starting as fresh download.. but i want to restart from where i have closed..

2)How to know size of file using Qftp on server side

3)do i have any other possibilite other than QFtp for downloading file..

I suggest you read the
And an

These documents contain the answers to your questions 1) and 2)

You can download a file using traditional TCP sockets (Q3Socket), but I recommend using QFtp.

the documents which u have given belongs to qt4.6 but i am working in qt3.3.0 version.. so their are some modifications like---> in get method their is no third parameter i.e QFtp::binary

Sorry, is the Qt3 version of QFtp.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.