How to access the data received from FTP server?
-
Hi, I've been using this(https://doc.qt.io/qt-6/qtscxml-ftpclient-example.html) ftp client to receive data from ftp server and it's working as intended.
It displays the text inside the txt file in application output.
But my question here is how can I access it? Where is it stored? I want to write it to some other file.
Actually I want to get an xml file from ftp client and save it to my computer that's my purpose.
Thanks in advance.
-
@kayakaan02 This is the place where data is received:
QObject::connect(&dataChannel, &FtpDataChannel::dataReceived, [](const QByteArray &data) { std::cout << data.constData() << std::flush; });
Instead of simply printing it out you can accumulate the data returned by data.constData() in a member variable of type QByteArray. When the whole file was transferred you will have all the data in that member variable.
Keep in mind that you should not do it this way if transferred file is big. In this case you can write what data.constData() returns into a file. -
@jsulm Thanks, how did I not see that :D.
Also I assume I cannot take this as a file and directly save it?
I have to take what I have and save it into a file so that means more work?
-
@kayakaan02
nothing prevents you from saving the bytearray directly to a file. -
@kayakaan02 said in How to access the data received from FTP server?:
Also I assume I cannot take this as a file and directly save it?
Of course you can. I also wrote it in my previous post...