From 9a3df93f65511f22553ec393f92db4c6ed90426a Mon Sep 17 00:00:00 2001 From: fabiovandewaeter <vandewaeter.fabio@gmail.com> Date: Sun, 23 Mar 2025 17:25:36 +0100 Subject: [PATCH] readme --- README.md | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 73 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 1580d8e..b6b8321 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,75 @@ La vidéo `video.mp4` montre pas à pas comment utiliser ce projet On commence par compiler puis démarrer le programme `FlopBox`, puis on démarre 2 serveurs FTP sur les ports `2121` et `2122` et l'utilisateur `user/password` -En haut à droite se trouve le dossier du serveur1 `dossier_serveur_ftp1` et en dessous le dossier du serveur2 `dossier_serveur_ftp2`, qui sont vides au départ +En haut à droite se trouve le dossier du serveur1 `dossier_serveur_ftp1` et en dessous le dossier du serveur2 `dossier_serveur_ftp2` + +Ensuite la vidéo présente les exemples suivants dans l'ordre : + +#### 1) Exemple ajouter un serveur FTP + +On ajoute les deux serveurs avec les alias `mon-ftp` et `mon-ftp2` : + +```shell +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 +``` + +```shell +curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer valid-token-1" -d '{"alias":"mon-ftp2","host":"localhost","port":2122}' http://localhost:8080/ftps +``` + +On ajoute aussi un `mon-ftp3` simplement pour voir que l'on peut le modifier et le supprimer avec les commandes suivantes : + +- lister les serveurs : +```shell +curl -X GET -H "Authorization: Bearer valid-token-1" http://localhost:8080/ftps +``` + +- ajout : +```shell +curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer valid-token-1" -d '{"alias":"mon-ftp3","host":"localhost","port":2123}' http://localhost:8080/ftps +``` + +- modification : +```shell +curl -X PUT http://localhost:8080/ftps/mon-ftp3 -H "Content-Type: application/json" -H "Authorization: Bearer valid-token-1" -d '{"alias":"mon-ftp3","host":"nouvelle-adresse","port":9999}' +``` + +- suppression : +```shell +curl -X DELETE -H "Authorization: Bearer valid-token-1" http://localhost:8080/ftps/mon-ftp3 +``` + +#### 2) Exemple affichage de l'arborescence + +On voit qu'avec la commande suivante on reçoit un JSON avec l'arborescence du serveur2 qui contient déjà un dossier avec un fichier : + +```shell +curl -X GET -H "Authorization: Bearer valid-token-1" -H "X-FTP-User: anonymous" -H "X-FTP-Pass: anonymous" localhost:8080/ftps/list/mon-ftp2/ +``` + +#### 3) Exemple créer dossier et fichier vide, et les supprimer sur le serveur1 + +On crée un dossier vide `dossier1` sur le serveur1 puis on le renomme en `dossier1_nouveau_nom`, et on crée un fichier dans ce dossier nommé `fichier` : + +- créer dossier : +```shell +curl -X POST -H "X-Resource-Type: folder" -H "Authorization: Bearer valid-token-1" -H "X-FTP-User: user" -H "X-FTP-Pass: password" http://localhost:8080/ftps/mon-ftp/dossier1 +``` + +- renommer le dossier : +```shell +curl -X PUT -H "Authorization: Bearer valid-token-1" -H "X-FTP-User: user" -H "X-FTP-Pass: password" -H "Content-Type: text/plain" -d "dossier1_nouveau_nom" http://localhost:8080/ftps/mon-ftp/rename/dossier1 +``` + +- créer fichier : +```shell +curl -X POST -H "X-Resource-Type: file" -H "Authorization: Bearer valid-token-1" -H "X-FTP-User: user" -H "X-FTP-Pass: password" http://localhost:8080/ftps/mon-ftp/dossier1_nouveau_nom/fichier +``` + +- supprimer dossier : +```shell +curl -X DELETE -H "Authorization: Bearer valid-token-1" -H "X-FTP-User: user" -H "X-FTP-Pass: password" http://localhost:8080/ftps/mon-ftp/dossier1_nouveau_nom +``` ## Instructions de build et d'exécution SANS la vidéo ### Build l'archive @@ -139,14 +207,14 @@ curl -X GET -H "Authorization: Bearer valid-token-1" http://localhost:8080/ftps 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 ``` -- suppression : +- modification : ```shell -curl -X DELETE -H "Authorization: Bearer valid-token-1" http://localhost:8080/ftps/mon-ftp +curl -X PUT http://localhost:8080/ftps/mon-ftp -H "Content-Type: application/json" -H "Authorization: Bearer valid-token-1" -d '{"alias":"mon-ftp","host":"nouvelle-adresse","port":2221}' ``` -- modification : +- suppression : ```shell -curl -X PUT http://localhost:8080/ftps/mon-ftp -H "Content-Type: application/json" -H "Authorization: Bearer valid-token-1" -d '{"alias":"mon-ftp","host":"nouvelle-adresse","port":2221}' +curl -X DELETE -H "Authorization: Bearer valid-token-1" http://localhost:8080/ftps/mon-ftp ``` **Note comprise entre 14 et 15 si—en plus—le proxy FlopBox, permet de créer, supprimer, renommer une ressource directement sur l'un des serveurs FTP gérés (fichier ou répertoire):** -- GitLab