Java file transfer through HTTP - Why Awake File?

Why is it so complicated with Java to access files on a remote Java Servlet container ?

For example, why is it so complicated to code the upload of a file from an Android device or a PC Desktop to a remote Tomcat or other JavaEE server for treatment by a Servlet? Java developers have no easy built in APIs or tools to handle this. There is the solution to set up a FTP server but it’s cumbersome: it requires amendments to security rules and new developments to link the uploaded file to Tomcat or other JavaEE Servlet Server. Another solution is to use client and server libraries (Apache Commons HttpClient, FileUpload, etc.), but you have to write, test and maintain the code, define the security rules, handle proxy considerations, manage the errors, etc.


Awake File is our attempt to offer an easy solution for:

  • Uploading files to a remote servlet server.
  • Downloading files from a remote servlet server.
  • Listing remote directories.
  • Creating/deleting remote directories.
  • Calling a remote java method without complicated setup.
  • Defining strong security rules for all these operations.
  • Displaying nice progress indicators to your users during uploads & downloads.

Examples - File upload through HTTP & Remote Java method call

This snippet shows how to upload a file with few lines of code:

  // Create an AwakeFile instance and username on the remote server
  // using the URL of the path to the AwakeFileManager Servlet
  String url = "https://www.acme.org/AwakeFileManager";

  // The login info for strong authentication on server side:
  String username = "myUsername";
  char[] password = 'm''y''P''a''s''s''w''o''r''d' };

  // Create the Awake Session with the remote server
  AwakeFileSession awakeFileSession = new AwakeFileSession(url, username,
    password);

  // OK: upload a file
  awakeFileSession.upload(new File("c:\\myFile.txt"),
    "/home/mylogin/myFile.txt");


There is no programming on the server side (except few lines for files location and security settings if required, see the Tutorial).

This snippet shows how to call a remote Java method:

  AwakeFileSession awakeFileSession = new AwakeFileSession(url, username,
    password);

  // OK: call the add(int a, int b) remote method that returns a + b:
  String result = awakeFileSession.call(
    "org.awakefw.examples.Calculator.add"3344);
  System.out.println("Calculator Result: " + result);