Bonsoir,
Je cherche à télécharger un fichier zip depuis un serveur web en utilisant la classe HTTPStreamFactory de la lib POCO 1.5.0.
L'échange se fait en HTTPS.
J'ai bien regardé l'exemple qu'ils donnent dans leur version full : il consiste à télécharger un fichier texte et à l'afficher dans la console.
J'aimerais pouvoir écrire ce que j'ai téléchargé non dans la console mais dans un fichier binaire. Est-ce possible avec StreamCopier::copyStream ? Si oui, où puis-je trouver une démo de la chose?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 #include "Poco/URIStreamOpener.h" #include "Poco/StreamCopier.h" #include "Poco/Path.h" #include "Poco/URI.h" #include "Poco/Exception.h" #include "Poco/Net/HTTPStreamFactory.h" #include "Poco/Net/FTPStreamFactory.h" #include <memory> #include <iostream> using Poco::URIStreamOpener; using Poco::StreamCopier; using Poco::Path; using Poco::URI; using Poco::Exception; using Poco::Net::HTTPStreamFactory; using Poco::Net::FTPStreamFactory; try { HTTPStreamFactory::registerFactory(); FTPStreamFactory::registerFactory(); URI uri(argv[1]); std::auto_ptr<std::istream> pStr(URIStreamOpener::defaultOpener().open(uri)); StreamCopier::copyStream(*pStr.get(), std::cout); } catch (Exception& exc) { std::cerr << exc.displayText() << std::endl; return 1; }
Je pense qu'en ce qui concerne la décompression du fichier Zip en question, la couche Zip m'apportera tout le support dont j'ai besoin.
Merci par avance pour cette réponse
Partager