Mediaflux Plugin Development: Create dataset from HTTP URL (with Basic Auth)

The example shows how to create a dataset asset from a password protected URL (Basic HTTP Auth).

Java: HTTP GET data from URL (with basic HTTP Auth)

The example shows how to do HTTP GET to download a file from URL. It also include an example to call Mediaflux client api to create a dataset from the url by piping the streams.

encode Base64 string in command line

  • Encode base64 string:
    echo -n Secret | base64
  • Decode base64 string:
    echo -n U2VjcmV0 | base64 -D


When encoding, -n must be specified. otherwise, a newline character will always be appended, which will cause unexpected result.


Maven: skip unit tests


make Java HttpURLConnection support MKCOL PROFIND and other non-standard HTTP methods

    private static void setRequestMethod(HttpURLConnection conn, String method) throws Throwable {
        try {
        } catch (ProtocolException e) {
            Class<?> c = conn.getClass();
            Field methodField = null;
            Field delegateField = null;
            try {
                delegateField = c.getDeclaredField("delegate");
            } catch (NoSuchFieldException nsfe) {

            while (c != null && methodField == null) {
                try {
                    methodField = c.getDeclaredField("method");
                } catch (NoSuchFieldException nsfe) {

                if (methodField == null) {
                    c = c.getSuperclass();
            if (methodField != null) {
                methodField.set(conn, method);

            if (delegateField != null) {
                HttpURLConnection delegate = (HttpURLConnection) delegateField.get(conn);
                setRequestMethod(delegate, method);