Last active
April 9, 2018 15:09
-
-
Save rivmar/46414aaad4f9d63c209190bd96cda7bd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<QCoreApplication> | |
#include<QNetworkAccessManager> | |
#include<QNetworkReply> | |
#include<QFile> | |
int getFile(char str[], char out[]) | |
{ | |
QUrl url(str); | |
QNetworkAccessManager manager(0); | |
QNetworkReply * reply = manager.get(QNetworkRequest(url)); | |
QEventLoop loop; | |
QObject::connect(reply,SIGNAL(finished()),&loop,SLOT(quit())); | |
loop.exec(); | |
QFile file(out); | |
file.open(QIODevice::WriteOnly); | |
file.write(reply->readAll()); | |
delete reply; | |
return 0; | |
} | |
int main(int argc,char * argv[]) | |
{ | |
QCoreApplication app(argc,argv); | |
char cPath[256]="ftp://username:password@my.server.com:2121/myfile.jpg"; | |
char cOutFileName[32] = "out.jpg"; | |
printf("Загрузка ... "); | |
getFile(cPath,cOutFileName); | |
printf("Готово\n"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment