diff --git a/README.md b/README.md index 8065859025f26787d04b3827768c54ed9eeb48fa..87b1645a0d4238312094846bdb1800185f191b5e 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,14 @@ Pour exécuter uniquement les tests il faut lancer la commande suivante : mvn test ``` +``` +curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer valid-token-1" -d '{"alias":"mon-ftp","host":"localhost","port":2121}' http://localhost:8080/ftps + +curl -H "Authorization: Bearer valid-token-1" http://localhost:8080/ftps -v + +curl -H "Authorization: Bearer valid-token-1" -o fichier.html http://localhost:8080/ftps/mon-ftp/test/download -v +``` + ## Détails du code ### Générer la javadoc Lancer la commande suivante : diff --git a/src/main/java/fil/sr2/flopbox/FTPResource.java b/src/main/java/fil/sr2/flopbox/FTPResource.java index 521c49111feeac211c20b4afaf10a81b0e8bd620..7e199da20f28a15fddfa1cf599f63d3035a6cfb9 100644 --- a/src/main/java/fil/sr2/flopbox/FTPResource.java +++ b/src/main/java/fil/sr2/flopbox/FTPResource.java @@ -102,7 +102,12 @@ public class FTPResource { try { ftp.connect(config.getHost(), config.getPort()); ftp.login(user, pass); + // path = "/home/m1gl/fabio.vandewaeter.etu/M1/SR2/serveur-ftp-test/" + path; InputStream is = ftp.retrieveFileStream(path); + if (is == null) { + return Response.status(Response.Status.INTERNAL_SERVER_ERROR) + .entity("Could not retrieve file : " + path).build(); + } return Response.ok(is) .header("Content-Disposition", "attachment; filename=\"" + getFileName(path) + "\"") .build();