Opened 17 years ago
Closed 16 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: |
Description
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 follow-up: 3 Changed 17 years ago by
comment:2 Changed 17 years ago by
Keywords: | Pending added; cluster file upload UserPathBuilder removed |
---|
comment:3 Changed 17 years ago by
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);
with
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 17 years ago by
Andrew,
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 16 years ago by
Keywords: | Confirmed added; Pending removed |
---|---|
Milestone: | → FCKeditor.Java 2.5 |
Priority: | Normal → High |
Resolution: | → duplicate |
Status: | new → closed |
Version: | → FCKeditor.Java 2.4 Beta |
DUP of #28
Andrew,
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?