download a folder with QNetworkAccessManager instead of File
-
Hello guys, i made a program to download from FTP server using QNEtworkAcessManager, but the problem is that i can download only file, is it possible to download the folder who contains the files ?
when i give the URL of the folder it didn't work, it only work with file , Thanks
-
I don't think you can directly download a folder. But you may zip the folder, download the zip and unzip on cpp.
QProcess myproc; QStringList args; QString mydestination = QString("%1/myfile.zip").arg(filepath); //the variable 'filepath' should be a string of your file. //If you dont want it to be a variable, you may change the line like, //QString mydestination = QString("/home/somewhere/myfile.zip"); if(QFileInfo::exists(mydestination)) { args<<"unzip"<<cf<<"-d"<<filepath; myproc.start("sudo",args); myproc.waitForFinished(50000); //Change as the time you need myproc.kill(); return true; }else{ return false; }
This code will make you have your files under the folder /home/somewhere/myfile/
-
Hello guys, i made a program to download from FTP server using QNEtworkAcessManager, but the problem is that i can download only file, is it possible to download the folder who contains the files ?
when i give the URL of the folder it didn't work, it only work with file , Thanks
@Zunneh
FTP protocol does not have "download directory with contents". You have to do your own file-at-a-time. IIRC there is anmget
(multi-get) command which accepts a*
wildcard, but I don't know if that's any use toQNetworkAcessManager
.From what I've seen of
QNetworkAcessManager
methods it does not seem to have some kind oflist()
either. That means you won't be able to get a list of folder contents from server so that you can then ask it to download each one. (Unless your attempt toget()
the folder URL returned anything like a list of files?) If that is correct, you are going to have a problem trying to download an arbitrary folder's contents.... -
Start reading here...