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 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
| @WebMethod(operationName = "recupPhoto")
public String recupPhoto(@WebParam(name = "nom")
String nom, @WebParam(name = "apercu")
Integer apercu, @WebParam(name = "chemin")
String chemin) {
if(apercu==0){
try{
// Populate these variables with the necessary info.
String host = "mediaisep.franceserv.com";
String username = "****";
String password = "****";
String remotePath = "";
String localPath = "";
FTPClient ftp;
// set up client
ftp = new FTPClient();
ftp.setRemoteHost(host);
// connect
System.out.println ("Connecting");
ftp.connect();
// login
System.out.println ("Logging in");
ftp.login(username, password);
// set up passive ASCII transfers
System.out.println ("Setting up passive, ASCII transfers");
ftp.setConnectMode(FTPConnectMode.PASV);
ftp.setDetectTransferMode(true);
ftp.setType(FTPTransferType.ASCII);
// copy file to server
System.out.println ("Putting file");
ftp.get("temp/" + nom,"mediaisep.franceserv.com/" + nom);
// Shut down client
System.out.println ("Quitting client");
ftp.quit();
return "OK";
}
catch(Exception err)
{
return "Erreur Serveur : " + err;
}
}
else if(apercu==1){
return null;
}
return null;
} |
Partager