Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

This article is a Private article. Only a writer and users who know the URL can access it.
Please change open range to public in publish setting if you want to share this article with other users.

More than 1 year has passed since last update.

Web File Management with One Tag

Posted at

First, the main dinner. You can use the web file management function with the following few lines of the program.

<%@ page language="java" contentType="text/html; charset=UTF-8"
     pageEncoding="UTF-8"%>
<%@ taglib prefix="efw" uri="efw" %>
<!DOCTYPE HTML>
<HTML>
<HEAD>
	<efw:Client lang="jp"/>
</HEAD>
<BODY>
	<efw:elFinder home=""/>
</BODY>
</HTML>

The screen image is explore style. Drag-and-drop file uploads, uploading and downloading multiple files and folders, right-click menus, etc. are quite vivid.
image.png

Background

elFinder is a fairly famous file management tool. It is created with JavaScript and php. Click here for the Motoie website.

If you want to use it in Java, you need to create a connector. efw customized the elFinder JavaScript library, added connectors, and packaged it in a jar file in the form of jsp tags. It is one of the "3rd party connectors" on the elFinder Motoie site.

Get Jar

It can be downloaded from maven.

<dependency>
    <groupId>io.github.efwgrp</groupId>
    <artifactId>efw</artifactId>
    <version>4.07.000</version>
</dependency>

For jdk15 or higher, related jars are required.

<dependency>
    <groupId>org.openjdk.nashorn</groupId>
    <artifactId>nashorn-core</artifactId>
    <version>15.4</version>
</dependency>

efw's elFinder tag

Usage is simple. The minimal way to write it is as described above. The home attribute is a relative path to the WEB-INF/efw/storage folder of the web application. If you want to use an absolute path, set the isAbs attribute to true.

<!--相対パス->
<efw:elFinder home="upload"/>
<!--絶対パス-->
<efw:elFinder home="C:\Windows\Microsoft.NET\Framework64" isAbs="true"/>

If you delete a file from elFinder, it will really disappear, so please be careful.
image.png

known limitations

I would like to explain some of the limitations that I know from my experience with actual projects.

Upload file capacity

You can upload files with a size of about 200-300MB at a time. You are free to use it multiple times. Downloads are also about the same size. It is not yet possible to upload and download files that ignore size like Giga File Express.

In the case of the original elFinder, it seems that you can upload larger files because it uses file division upload technology. If you need a larger size, please try using elFinder Motoie. It's php, not java.

File count limit

I haven't yet come up with specific numbers for this, but if there are a large number of files in one folder, it will not be possible to keep up with the size and an error will occur. For example, when I home the c:\windows folder, an error occurs. In the case of the original elFinder, the error is avoided by stopping obtaining the folder size.

If there are tens of thousands of files directly under one folder, it is assumed that the JSON data needed to display them will become huge and memory overflow will occur.

Explanation

For details of the API, see the link below.
https://github.com/efwGrp/efw4.X/blob/master/help/tag.elfinder.md
The main attributes and methods are absolute/relative paths, protection, home folder settings, and read-only flag switching. Without absolute path protection, it is extremely dangerous on the Internet. Assuming a simple hack of browser console JavaScript execution, if you find ".." in the home folder name, it is an error. Also, in protected mode, setting the home folder and read-only flag causes an error.
image.png
image.png

The above evidence program can be obtained from the link below.

0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?