Git Product home page Git Product logo

richfilemanager-java's Introduction

Java connector for RFM plugin

This is a (quick) conversion of the RFM PHP connector tested with Spring MVC. The code needs to be refactored and fully unit tested, but it can be already used.

Requirement:

  • Servlet API >= 3.1+
  • Java >= 7

Demo project

Example with Spring MVC

Installation

Plugin configuration (JavaScript side)

Set the connectorUrl (filemanager.config.js)

 "api": {
        ...
        "connectorUrl": "/your/path/to/api",
        ...
    }

Set the previewUrl to false (filemanager.config.js)

We will use the connector to show images

"viewer": {
  ...
  "absolutePath": false,
   ...
}

Set the base Url in the initialisation of the connector

The path where your RFM JS plugin is located

$('.fm-container').richFilemanager({
   baseUrl: "/your/path/to/fm/folder",
});

Java side

Add the repository as dependecy

The easiest way to do that is to use JitPack.io

Here is an example with Gradle (there a maven example available in the JitPack repository)

    allprojects {
        repositories {
            jcenter()
            maven { url "https://jitpack.io" }
        }
   }
   dependencies {
        compile 'com.github.fabriceci:RichFilemanager-JAVA:master-SNAPSHOT'
   }

(Spring MVC) Create a controller to handle the manager

@Controller
@RequestMapping(value = "/admin/fileManager")
public class AdminFileManagerController {

    @RequestMapping(value = "", method = RequestMethod.GET)
    public String index(ModelMap model, HttpServletRequest request, HttpServletResponse response) throws IOException {
        //content of the index.html in the (JS) plugin's folder
        return "admin/rfm/home";
    }

    @RequestMapping(value = "/api")
    public void fm(ModelMap model, HttpServletRequest request, HttpServletResponse response) throws IOException, FileManagerException {
        new LocalFileManager().handleRequest(request, response);
    }
}

configuration

There are two ways to override the configuration. Please read the filemanager.config.default.properties to have more information.

Add a file property

Add to your resources folder the file: filemanager.config.default.properties to override the default configuration

Override during runtime

You can pass a property Map into the constructor:

@RequestMapping(value = "fm/api")
public void fm(ModelMap model, HttpServletRequest request, HttpServletResponse response) throws IOException, FileManagerException {
        Map<String,String> options = new HashMap<>();
        options.put("propertyName", "value");
        new LocalFileManager(options).handleRequest(request, response);
}

Note

It's optional, but I strongly recommend to add the twelvemonkeys library to avoid errors during thumbnail generations.

compile('com.twelvemonkeys.imageio:imageio-jpeg:3.3.+');

richfilemanager-java's People

Contributors

fabriceci avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.