Opened 11 years ago

Closed 11 years ago

#2229 closed New Feature (duplicate)

Java Connector: enable file upload to directory outside webapp context root

Reported by: AndrewCottrell Owned by:
Priority: Must have (possibly next milestone) Milestone: FCKeditor.Java 2.5
Component: Server : Java Version: FCKeditor.Java 2.4 Beta
Keywords: Confirmed Cc:


Sorry if this is a dupe.

I have four clustered webservers running a single webapp (with a reverse proxy performing round-robin with sticky server sessions). So, whenever I need file upload I use a server-side directory that is a mounted remote file system, shared between all four webservers. This directory is mapped into the URL space (context) of the webapp on each server using their server.xml configuration files.

I'd like to create a subdirectory of this shared directory to store the uploaded files (mostly images) from the FCKeditor.

I imagine a new method on the UserPathBuilder interface, so that I can specify the file system directory (in addition to the URL specified by the getUserFilesPath method).

Change History (5)

comment:1 Changed 11 years ago by Michael Osipov


I do not completely understand what you want because your statements are to some degree contrary.

you want to deploy outside of ${catalina.home}/webapps/myapp or do you want to deploy in an arbitrary dir in ${catalina.home}/webapps/myapp?

if your symlinks map to a folder within the context it should work already, shouldn't it?

are you working with: <DefaultContext allowLinking="true"/> in the server.xml?

comment:2 Changed 11 years ago by Wojciech Olchawa

Keywords: Pending added; cluster file upload UserPathBuilder removed

comment:3 in reply to:  1 Changed 11 years ago by AndrewCottrell

Thanks for taking time to review my request. I'm sorry I didn't make it clearer.

I deploy my webapp to ${catalina.home}/webapps/ROOT on each of four servers.

My problem is that

String typeDirPath = getServletContext().getRealPath(typePath);

returns the wrong directory (although typePath is correct).

Each server has a 'shared' directory mounted as /mnt/shared

In each server.xml file I have:

<Context path="/shared" docBase="/mnt/shared" />

So, I want typePath to get the value "/shared/fckeditor/image" and I want typeDirPath to get the value "/mnt/shared/fckeditor/image"

For security reasons I'm unable set symlinks. I have now patched fckeditor-java-core-2.4-beta-1.jar to do what I need.

I modified doGet and doPost in ConnectorServlet with

String typeDirPath = UtilsResponse.constructSystemFilePath(request, resourceType, currentFolderStr);

and added constructSystemFilePath to UtilsResponse. That method is almost the same as constructResponseUrl and calls ConnectorHandler.getUserSystemFilesPath(request) which in turn calls RequestCycleHandler.getUserSystemFilePath(servletRequest) which calls userPathBuilder.getUserSystemFilesPath(request). Obviously I added getUserSystemFilesPath to UserPathBuilder.

This change allows me to implement different code for determining the typePath and the typeDirPath. I doubt that my patch would be useful for anyone else. I'm sure you could implement the same functionality in a much more maintainable way.

btw, I ran into a problem in ConnectorServlet.doGet where the currentFolderStr value appears twice in currentDir. I think this may be a bug in fckeditor-java-core-2.4-beta-1. I fixed this issue by replacing

File currentDir = new File(typeDir, currentFolderStr);


File currentDir = typeDir;

[I got a database error when I tried to submit this reply. Will try again. Sorry if multiple copies of this reply end up online.]

comment:4 Changed 11 years ago by Michael Osipov


now I fully understand your intention. You want to upload to any dir on the server, in your case it's just a cross-context path.

Yes, this is an intentional limitation in this version, we did not want to change too much this time. Please take a look at ticket #28. This is exactly what you want with an abstract interface. We intend to do this in the next major relaease (2.5).

For you did the right and a good thing patching yourself. It would be great if you could provide patches for our future consideration.

For the 2 bugs you have found, please create two separate tickets with how-to reproduce steps.

Again, this feature is definitively planned for the near future!

We are aware of the database already and our provider is working on it.

comment:5 Changed 11 years ago by Michael Osipov

Keywords: Confirmed added; Pending removed
Milestone: FCKeditor.Java 2.5
Priority: NormalHigh
Resolution: duplicate
Status: newclosed
Version: FCKeditor.Java 2.4 Beta

DUP of #28

Note: See TracTickets for help on using tickets.
© 2003 – 2019 CKSource – Frederico Knabben. All rights reserved. | Terms of use | Privacy policy