diff --git a/FlopBox/pom.xml b/FlopBox/pom.xml index acb87b8485542ba3a6d8b0b0d11d56de53069abf..02513e56bc189d2f369067467ab3c56ad04f5fae 100644 --- a/FlopBox/pom.xml +++ b/FlopBox/pom.xml @@ -103,6 +103,15 @@ <target>1.8</target> </configuration> </plugin> +<plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-javadoc-plugin</artifactId> + <version>3.2.0</version> + <configuration> + <source>8</source> + </configuration> +</plugin> + <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> diff --git a/FlopBox/src/main/java/com/example/rest/ConnectionServerException.java b/FlopBox/src/main/java/com/example/rest/ConnectionServerException.java index 3acc45a7e4341c7185ee3f911c8e0be9e9d492b7..e2bd99bf5073552be06ae1de5e4c7b7395f5db26 100644 --- a/FlopBox/src/main/java/com/example/rest/ConnectionServerException.java +++ b/FlopBox/src/main/java/com/example/rest/ConnectionServerException.java @@ -1,5 +1,9 @@ package com.example.rest; +/** + * @author Kevin Nguyen + */ + public class ConnectionServerException extends Exception { public ConnectionServerException(String msg) { diff --git a/FlopBox/src/main/java/com/example/rest/FTPServerException.java b/FlopBox/src/main/java/com/example/rest/FTPServerException.java index 72e0d02919b991590ea5da4488ab392f6f9ccfe2..05a962b640f82ae15fa928b48a804ad5d64d5a3f 100644 --- a/FlopBox/src/main/java/com/example/rest/FTPServerException.java +++ b/FlopBox/src/main/java/com/example/rest/FTPServerException.java @@ -1,9 +1,13 @@ package com.example.rest; +/** + * @author Kevin Nguyen + */ + public class FTPServerException extends Exception { - + public FTPServerException(String msg) { super(msg); } - + } diff --git a/FlopBox/src/main/java/com/example/rest/FtpClient.java b/FlopBox/src/main/java/com/example/rest/FtpClient.java index 73b1059c9a6402dcaf49f830495300d9a4b76620..3aae52da6a5a31d80a3010edeb21ba2f44ed5384 100644 --- a/FlopBox/src/main/java/com/example/rest/FtpClient.java +++ b/FlopBox/src/main/java/com/example/rest/FtpClient.java @@ -1,228 +1,324 @@ package com.example.rest; +/** + * @author Kevin Nguyen + */ + import java.io.*; -import org.apache.commons.net.SocketClient; import org.apache.commons.net.ftp.FTP; import org.apache.commons.net.ftp.FTPClient; import org.apache.commons.net.ftp.FTPFile; import org.apache.commons.net.ftp.FTPReply; -import java.net.*; -import java.util.Arrays; +/** + * Create an FTP client to interact with the FTP servers. + */ public class FtpClient extends FTP { - private FTPClient client; - private String username; - private String password; - private String server; - private int port; - private int replyCode; - private boolean error = false; - - public FtpClient(String server, int port, String username, String password) { - - this.client = new FTPClient(); - this.username = username; - this.password = password; - this.server = server; - this.port = port; - } - - private FTPClient getClient() { - return this.client; - } - - private String getUsername() { - return this.username; - } - - private String getPassword() { - return this.password; - } - - private String getServer() { - return this.server; - } - - private int getPort() { - return this.port; - } - - public boolean getError() { - return this.error; - } - - public void connect() throws ConnectionServerException, FTPServerException { - try { - System.out.println("nom du serveur : " + this.getServer()); - this.getClient().connect(this.getServer(), this.getPort()); - System.out.println("Connecting to " + this.getServer() + "."); - System.out.print(this.getClient().getReplyString()); - - // After connection attempt, you should check the reply code to verify - // success. - this.replyCode = this.getClient().getReplyCode(); - - if(!FTPReply.isPositiveCompletion(this.replyCode)) { - this.disconnectClient(); - throw new ConnectionServerException("Error connection to the FTP server refused."); - } - } - catch(IOException e) { - throw new FTPServerException("Error connecting to the FTP server."); - } - } - - public void login() throws LoginException, FTPServerException { - try { - System.out.println("username and password : " + this.getUsername()+ " " + this.getPassword()); - boolean successLogged = this.getClient().login(this.getUsername(), this.getPassword()); - if (successLogged) { - System.out.println("LOGGED IN SERVER"); - } - else { - this.disconnectClient(); - throw new LoginException("Error login or password wrong."); - } - } - catch(IOException e) { - throw new FTPServerException("Error trying login."); - - } - } - - public void logout() throws LogoutException, FTPServerException { - try { - boolean successLogged = this.getClient().logout(); - if (successLogged) { - System.out.println("LOGGED OUT FROM SERVER"); - } - else { - throw new LogoutException("Error loggin out."); - } - } - catch(IOException e) { - throw new FTPServerException("Error trying logout."); - - } - } - - public void disconnectClient() throws FTPServerException { - try { - this.getClient().disconnect(); - System.out.println("DISCONNECTED FROM SERVER"); - } - catch(IOException e) { - throw new FTPServerException("Error disconnection impossible"); - } - } - - public String listDirectory(String pathFile) throws FTPServerException { - FTPFile[] infoFiles; + private FTPClient client; + private String username; + private String password; + private String server; + private int port; + private int replyCode; + private String root = "/tmp/"; + + /** + * Create an FTP client to interact with a FTP server. + * + * @param server the name of the server to connect. + * @param port the port to which to connect to the server. + * @param username the username to use with the FTPClient. + * @param password the password to use with the FTPClient. + */ + public FtpClient(String server, int port, String username, String password) { + + this.client = new FTPClient(); + this.username = username; + this.password = password; + this.server = server; + this.port = port; + } + + /** + * Get the FTPClient. + * + * @return The FTPClient. + */ + private FTPClient getClient() { + return this.client; + } + + /** + * Get the username used with the FTPClient. + * + * @return the username. + */ + private String getUsername() { + return this.username; + } + + /** + * Get the password used with the FTPClient. + * + * @return The password. + */ + private String getPassword() { + return this.password; + } + + /** + * Get the server to which the FTPClient connect with. + * + * @return The server. + */ + private String getServer() { + return this.server; + } + + /** + * Get the port to use to connect to the FTP server. + * + * @return The port. + */ + private int getPort() { + return this.port; + } + + /** + * Connect to the server. + * + * @throws ConnectionServerException if there is a technical error connecting to + * the FTP server. + * @throws FTPServerException if the login to the FTP server is refused. + */ + public void connect() throws ConnectionServerException, FTPServerException { + try { + this.getClient().connect(this.getServer(), this.getPort()); + this.replyCode = this.getClient().getReplyCode(); // on check le code de retour. + if (!FTPReply.isPositiveCompletion(this.replyCode)) { + this.disconnectClient(); + throw new ConnectionServerException("Error connection to the FTP server refused."); + } + } catch (IOException e) { + throw new FTPServerException("Error connecting to the FTP server."); + } + } + + /** + * Login to the server. + * + * @throws LoginException if there is a technical error login to the FTP + * server. + * @throws FTPServerException if the FTP server refuse to login the FTPClient. + */ + public void login() throws LoginException, FTPServerException { + try { + boolean successLogged = this.getClient().login(this.getUsername(), this.getPassword()); + if (!successLogged) { + this.disconnectClient(); + throw new LoginException("Error login or password wrong."); + } + } catch (IOException e) { + throw new FTPServerException("Error trying login."); + } + } + + /** + * Logout from the FTP server the FTPClient + * + * @throws LogoutException if there is a technical error logout to the FTP + * server. + * @throws FTPServerExceptionif the FTP server refuse to logout the FTPClient. + */ + public void logout() throws LogoutException, FTPServerException { + try { + boolean successLogged = this.getClient().logout(); + if (!successLogged) { + throw new LogoutException("Error loggin out."); + } + } catch (IOException e) { + throw new FTPServerException("Error trying logout."); + } + } + + /** + * Disconnect the FTPClient from the FTP server. + * + * @throws FTPServerException if there is a technical error making disconnection + * impossible. + */ + public void disconnectClient() throws FTPServerException { + try { + this.getClient().disconnect(); + } catch (IOException e) { + throw new FTPServerException("Error disconnection impossible"); + } + } + + /** + * List all the content of a folder from the FTP server. + * + * @param pathFolder The folder from which to display contents. + * @return a string containing all the informations of the contents of the + * folder. + * @throws FTPServerException if there is a technical error during the listing + * of the contents. + */ + public String listDirectory(String pathFolder) throws FTPServerException { try { - System.out.println("valeur de : "+ pathFile); + FTPFile[] infoFiles; this.getClient().enterLocalPassiveMode(); - infoFiles = this.getClient().listFiles(pathFile); + infoFiles = this.getClient().listFiles(pathFolder); String textInfo = ""; - for( FTPFile info : infoFiles) { - textInfo += info.getRawListing() + "\n"; - } - return textInfo; + for (FTPFile info : infoFiles) { + textInfo += info.getRawListing() + "\n"; + } + return textInfo; } catch (IOException e) { throw new FTPServerException("Error listing the directory"); } - } - - public void downloadFile(String pathFile) throws FTPServerException { - - try { - System.out.println("valeur de : "+ pathFile); + } - File file = new File("/tmp/"+pathFile); - if(!file.exists()) { + /** + * Download a file from the FTPServer. + * + * @param pathFile The path to the file to download from the FTP server. + * @throws FTPServerException if there is a technical error downloading the file + * from the FTP server. + */ + public void downloadFile(String pathFile) throws FTPServerException { + try { + File file = new File(root + pathFile); + if (!file.exists()) { file.getParentFile().mkdirs(); file.createNewFile(); } - OutputStream downloaded = new FileOutputStream(file, false); this.getClient().setFileType(FTPClient.BINARY_FILE_TYPE); this.getClient().enterLocalPassiveMode(); this.getClient().setAutodetectUTF8(true); String filename = changeToFileDirectory(pathFile); - System.out.println(this.getClient().printWorkingDirectory()); - System.out.println("filename : " + filename); - boolean success = this.getClient().retrieveFile(filename, downloaded); - if (!success) { - file.delete(); - } - downloaded.close(); - System.out.println("rIICIII"); - - } - catch (IOException e) { - throw new FTPServerException("Error listing the directory"); + boolean success = this.getClient().retrieveFile(filename, downloaded); + if (!success) { + file.delete(); + } + downloaded.close(); + } catch (IOException e) { + throw new FTPServerException("Error listing the directory"); } - } - - public void uploadFile(String pathFile, InputStream uploadInputStream) throws FTPServerException { - try { - System.out.println("TENTATIVE D'UPLOAD !!"); - System.out.println(pathFile); - this.getClient().setFileType(FTPClient.BINARY_FILE_TYPE); - this.getClient().enterLocalPassiveMode(); + } + + /** + * Upload a file to the FTP server. + * + * @param pathFile The path to the file to upload to the FTP server. + * @param uploadInputStream the inputstream of the file to upload. + * @return True if the upload succeed, false otherwise. + * @throws FTPServerException if there is a technical error uploading the file + * to the server. + */ + public boolean uploadFile(String pathFile, InputStream uploadInputStream) throws FTPServerException { + try { + this.getClient().setFileType(FTPClient.BINARY_FILE_TYPE); + this.getClient().enterLocalPassiveMode(); this.getClient().setAutodetectUTF8(true); - this.getClient().storeFile(pathFile, uploadInputStream); + boolean success = this.getClient().storeFile(pathFile, uploadInputStream); + uploadInputStream.close(); + return success; } catch (IOException e) { throw new FTPServerException("Error uploading the file"); } - } - - private String changeToFileDirectory(String pathFile) throws IOException { - String [] splitted = pathFile.split("/"); - for(int i = 0; i < splitted.length - 1; i++) { - this.getClient().changeWorkingDirectory(splitted[i]); - } - String filename = splitted[splitted.length-1]; - return filename; - } - - public boolean rename(String oldFilename, String newFilename) throws FTPServerException { - try { + } + + /** + * Change + * + * @param pathFile + * @return + * @throws IOException + */ + private String changeToFileDirectory(String pathFile) throws IOException { + String[] splitted = pathFile.split("/"); + for (int i = 0; i < splitted.length - 1; i++) { + this.getClient().changeWorkingDirectory(splitted[i]); + } + String filename = splitted[splitted.length - 1]; + return filename; + } + + /** + * Rename a file from the server. + * + * @param oldFilename The current name of the file in the FTP server. + * @param newFilename The new name to give to the file in the FTP server. + * @return True if the rename is successful, false otherwise. + * @throws FTPServerException if there is a technical error renaming the file. + */ + public boolean renameFile(String oldFilename, String newFilename) throws FTPServerException { + try { return this.getClient().rename(oldFilename, newFilename); } catch (IOException e) { throw new FTPServerException("Error renaming the file"); } - } - - public boolean deleteDirectory(String pathFolder) throws FTPServerException { - FTPFile[] files; - try { - System.out.println("valeur de : "+ pathFolder); - this.getClient().enterLocalPassiveMode(); - files = this.getClient().listFiles(pathFolder); - for( FTPFile file : files) { - if(file.isDirectory()) { - deleteDirectory(pathFolder + "/" + file.getName()); - } - else { - String filePath = pathFolder + "/" + file.getName(); - this.getClient().deleteFile(filePath); - } - } - return this.getClient().removeDirectory(pathFolder); - } - catch (IOException e) { + } + + /** + * Rename a directory from the server. + * + * @param oldDirectoryName The current name of the directory in the FTP server. + * @param newDirectoryName The new name to give to the directory in the FTP server. + * @return True if the rename is successful, false otherwise. + * @throws FTPServerException if there is a technical error renaming the + * directory. + */ + public boolean renameDirectory(String oldDirectoryName, String newDirectoryName) throws FTPServerException { + try { + return this.getClient().rename(oldDirectoryName, newDirectoryName); + } catch (IOException e) { + throw new FTPServerException("Error renaming the file"); + } + } + + /** + * Delete a directory from the FTP server. + * + * @param pathFolder The path to the folder to remove from the FTP server. + * @return True if the delete is successful, false otherwise. + * @throws FTPServerException if there is a technical error deleting the folder. + */ + public boolean deleteDirectory(String pathFolder) throws FTPServerException { + try { + FTPFile[] files; + this.getClient().enterLocalPassiveMode(); + files = this.getClient().listFiles(pathFolder); + for (FTPFile file : files) { + if (file.isDirectory()) { + deleteDirectory(pathFolder + "/" + file.getName()); + } else { + String filePath = pathFolder + "/" + file.getName(); + this.getClient().deleteFile(filePath); + } + } + return this.getClient().removeDirectory(pathFolder); + } catch (IOException e) { throw new FTPServerException("Error deleting folder."); } - } - - public boolean createDirectory(String pathFolder) throws FTPServerException { + } + + /** + * Create a directory in the FTP server. + * + * @param pathFolder The path to the folder to create in the FTP server. + * @return True if the creation is successful, false otherwise. + * @throws FTPServerException if there is a technical error deleting the folder. + */ + public boolean createDirectory(String pathFolder) throws FTPServerException { try { return this.getClient().makeDirectory(pathFolder); + } catch (IOException e) { + throw new FTPServerException("Error deleting folder."); } - catch (IOException e) { - throw new FTPServerException("Error deleting folder."); } -} - + } diff --git a/FlopBox/src/main/java/com/example/rest/ListException.java b/FlopBox/src/main/java/com/example/rest/ListException.java index beeec4c1f04655bf214649c18ec9d48c3244e1ae..a1fdea400810b4d9be6908a0bc5866a30f13044a 100644 --- a/FlopBox/src/main/java/com/example/rest/ListException.java +++ b/FlopBox/src/main/java/com/example/rest/ListException.java @@ -1,7 +1,11 @@ package com.example.rest; +/** + * @author Kevin Nguyen + */ + public class ListException extends Exception { - + public ListException(String msg) { super(msg); } diff --git a/FlopBox/src/main/java/com/example/rest/LoginException.java b/FlopBox/src/main/java/com/example/rest/LoginException.java index 56559f8b650fdc44cc1a22341c9bf91894b3a28a..349a35a64f2fd8fac1b19c88413964fe9c4ebf23 100644 --- a/FlopBox/src/main/java/com/example/rest/LoginException.java +++ b/FlopBox/src/main/java/com/example/rest/LoginException.java @@ -1,5 +1,9 @@ package com.example.rest; +/** + * @author Kevin Nguyen + */ + public class LoginException extends Exception { public LoginException(String msg) { diff --git a/FlopBox/src/main/java/com/example/rest/LogoutException.java b/FlopBox/src/main/java/com/example/rest/LogoutException.java index 3ea7efd1f7713cb3367d5edc7854efdb77d98d5a..b26a710bd42d65404947a5798922c8e8c332269d 100644 --- a/FlopBox/src/main/java/com/example/rest/LogoutException.java +++ b/FlopBox/src/main/java/com/example/rest/LogoutException.java @@ -1,5 +1,9 @@ package com.example.rest; +/** + * @author Kevin Nguyen + */ + public class LogoutException extends Exception { public LogoutException(String msg) { diff --git a/FlopBox/src/main/java/com/example/rest/Main.java b/FlopBox/src/main/java/com/example/rest/Main.java index ac42d19730d2e8b762c66bdaa8a0ac8e86fcfa31..27aea85e83e0592a542d4b45851241944a9d3fa2 100644 --- a/FlopBox/src/main/java/com/example/rest/Main.java +++ b/FlopBox/src/main/java/com/example/rest/Main.java @@ -13,49 +13,51 @@ import java.util.Optional; /** * Main class */ -public class Main{ - - // Base URI the Grizzly HTTP server will listen on - public static final String BASE_URI; - public static final String protocol; - public static final Optional<String> host; - public static final String path; - public static final Optional<String> port; - - static{ - protocol = "http://"; - host = Optional.ofNullable(System.getenv("HOSTNAME")); - port = Optional.ofNullable(System.getenv("PORT")); - path = "flopbox"; - BASE_URI = protocol + host.orElse("localhost") + ":" + port.orElse("8080") + "/" + path + "/"; - } - - /** - * Starts Grizzly HTTP server exposing JAX-RS resources defined in this application. - * @return Grizzly HTTP server. - */ - public static HttpServer startServer() { - // create a resource config that scans for JAX-RS resources and providers - // in com.example.rest package - final ResourceConfig rc = new ResourceConfig().packages("com.example.rest").register(MultiPartFeature.class); - - // create and start a new instance of grizzly http server - // exposing the Jersey application at BASE_URI - return GrizzlyHttpServerFactory.createHttpServer(URI.create(BASE_URI), rc); - } - - /** - * Main method. - * @param args - * @throws IOException - */ - public static void main(String[] args) throws IOException { - final HttpServer server = startServer(); - System.out.println(String.format("Jersey app started with WADL available at " - + "%sapplication.wadl\nHit enter to stop it...", BASE_URI)); - System.in.read(); - server.stop(); - //FtpClient test = new FtpClient("localhost", 2121, "anonymous", "1234"); - //test.connect(); - } +public class Main { + + // Base URI the Grizzly HTTP server will listen on + public static final String BASE_URI; + public static final String protocol; + public static final Optional<String> host; + public static final String path; + public static final Optional<String> port; + + static { + protocol = "http://"; + host = Optional.ofNullable(System.getenv("HOSTNAME")); + port = Optional.ofNullable(System.getenv("PORT")); + path = "flopbox"; + BASE_URI = protocol + host.orElse("localhost") + ":" + port.orElse("8080") + "/" + path + "/"; + } + + /** + * Starts Grizzly HTTP server exposing JAX-RS resources defined in this + * application. + * + * @return Grizzly HTTP server. + */ + public static HttpServer startServer() { + // create a resource config that scans for JAX-RS resources and providers + // in com.example.rest package + final ResourceConfig rc = new ResourceConfig().packages("com.example.rest").register(MultiPartFeature.class); + + // create and start a new instance of grizzly http server + // exposing the Jersey application at BASE_URI + return GrizzlyHttpServerFactory.createHttpServer(URI.create(BASE_URI), rc); + } + + /** + * Main method. + * + * @param args + * @throws IOException + */ + public static void main(String[] args) throws IOException { + final HttpServer server = startServer(); + System.out.println(String.format( + "Jersey app started with WADL available at " + "%sapplication.wadl\nHit enter to stop it...", + BASE_URI)); + System.in.read(); + server.stop(); + } } \ No newline at end of file diff --git a/FlopBox/src/main/java/com/example/rest/MyResource.java b/FlopBox/src/main/java/com/example/rest/MyResource.java deleted file mode 100644 index d64d46ef14ac66444a9e90146df41d3c8bd4f5f6..0000000000000000000000000000000000000000 --- a/FlopBox/src/main/java/com/example/rest/MyResource.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.example.rest; - -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; - -/** - * Root resource (exposed at "myresource" path) - */ -@Path("myresource") -public class MyResource { - - /** - * Method handling HTTP GET requests. The returned object will be sent - * to the client as "text/plain" media type. - * - * @return String that will be returned as a text/plain response. - */ - @GET - @Produces(MediaType.TEXT_PLAIN) - public String getIt() { - return "Got it!"; - } -} diff --git a/FlopBox/src/main/java/com/example/rest/ResourceFile.java b/FlopBox/src/main/java/com/example/rest/Resource.java similarity index 96% rename from FlopBox/src/main/java/com/example/rest/ResourceFile.java rename to FlopBox/src/main/java/com/example/rest/Resource.java index 63c5c3b35dad851827f0080411012f78992233f9..240b14ec244d7be36ba6e29305e103b6122f96df 100644 --- a/FlopBox/src/main/java/com/example/rest/ResourceFile.java +++ b/FlopBox/src/main/java/com/example/rest/Resource.java @@ -6,37 +6,24 @@ import javax.ws.rs.POST; import javax.ws.rs.PUT; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; -import javax.ws.rs.FormParam; import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.Response.ResponseBuilder; import org.glassfish.jersey.media.multipart.FormDataContentDisposition; -import org.glassfish.jersey.media.multipart.FormDataMultiPart; import org.glassfish.jersey.media.multipart.FormDataParam; -import org.glassfish.jersey.media.multipart.FormDataBodyPart; - -import java.io.ByteArrayOutputStream; import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; import java.io.InputStream; -import java.io.ObjectInputFilter.Config; -import java.io.OutputStream; -import java.nio.file.Files; import java.util.HashMap; import javax.ws.rs.Path; import javax.ws.rs.PathParam; -import java.util.List; -import java.util.Map; /** * Root resource (exposed at "RessourceFile" path) */ @Path("/") -public class ResourceFile { +public class Resource { private static HashMap<String, String> listServer = new HashMap<String, String>(); private ResponseBuilder response; @@ -238,7 +225,7 @@ public class ResourceFile { userClient.login(); // "/home/zomdex/Documents/MASTER_GL_1/Semestre 2b/SR2/sr2-projet1-flopbox/" pour le locahost - if (userClient.rename(pathFile, rename)) { + if (userClient.renameFile(pathFile, rename)) { loadResponse(200, "Fichier renommé.\n"); } else { diff --git a/INSTRUCTION.md b/INSTRUCTION.md index af643aee22cc1c5801ddf22044c90cd6b73106da..b9ea88b8b4176fc2ae53f0c06dd4c2ed45ae7797 100644 --- a/INSTRUCTION.md +++ b/INSTRUCTION.md @@ -1,13 +1,17 @@ -Initialisation: +Ajouter serveur: curl --location --request POST 'http://localhost:8080/flopbox/ftp.ubuntu.com' curl --location --request POST 'http://localhost:8080/flopbox/webtp.fil.univ-lille1.fr' +Mettre un alias: + curl --location --request PUT 'http://localhost:8080/flopbox/ftp.ubuntu.com' --header 'alias: alias1' curl --location --request PUT 'http://localhost:8080/flopbox/webtp.fil.univ-lille1.fr' --header 'alias: alias2' +Récuperer le nom du serveur : + curl --location --request GET 'http://localhost:8080/flopbox/alias1' curl --location --request GET 'http://localhost:8080/flopbox/alias2' @@ -19,27 +23,33 @@ curl --location --request GET 'http://localhost:8080/flopbox/alias1/' --header ' curl --location --request GET 'http://localhost:8080/flopbox/alias2/' --header 'username: nguyen' --header 'password: 6c7667d323' --header 'port: 21' -Download : +Download de fichier : curl --location --request GET 'http://localhost:8080/flopbox/alias1/file/cloud-images/FOOTER.html' --header 'username: anonymous' --header 'password: 1234' --header 'port: 21' -o TEST1.txt curl --location --request GET 'http://localhost:8080/flopbox/alias2/file/TEST.txt' --header 'username: nguyen' --header 'password: 6c7667d323' --header 'port: 21' -o TEST2.txt -Upload : +Upload de fichier : (Dans le dossier du fichier) -curl -v -X POST -F file=@image.jpg --header 'username: nguyen' --header 'password: 6c7667d323' http://localhost:8080/flopbox/alias2/image.jpg +curl -v -X POST -F file=@image.jpg --header 'username: nguyen' --header 'password: 6c7667d323' http://localhost:8080/flopbox/alias2/file/image.jpg + +Rename file: + +curl -v -X PUT --header 'rename: image2.jpg' --header 'username: nguyen' --header 'password: 6c7667d323' http://localhost:8080/flopbox/alias2/file/image.jpg + +Rename folder : +curl -v -X PUT --header 'rename: nini' --header 'username: nguyen' --header 'password: 6c7667d323' http://localhost:8080/flopbox/alias2/directory/nounou -Rename : -curl -v -X PUT --header 'rename: image2.jpg' --header 'username: nguyen' --header 'password: 6c7667d323' http://localhost:8080/flopbox/alias2/image.jpg Delete folder : -curl -v -X DELETE --header 'username: anonymous' --header 'password: 67d323' http://localhost:8080/flopbox/alias1/releases +curl -v -X DELETE --header 'username: anonymous' --header 'password: 67d323' http://localhost:8080/flopbox/alias1/directory/releases Create folder : -curl -v -X POST --header 'username: nguyen' --header 'password: 6c7667d323' http://localhost:8080/flopbox/alias2/coucou +curl -v -X POST --header 'username: nguyen' --header 'password: 6c7667d323' http://localhost:8080/flopbox/alias2/directory/coucou +