tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pid <...@pidster.com>
Subject Re: How to configuration rails upload directory in tomcat?
Date Tue, 19 Oct 2010 11:39:31 GMT
On 19/10/2010 02:25, Ray Sun wrote:
> Thanks all your response, let me clarify:
> 
> Here's my development environment:
> OS: Windows 7 6.1 x86
> Tomcat: Apache Tomcat/6.0.26
> Java: jdk1.6.0_21-b07
> Jruby: jruby 1.5.1 (ruby 1.8.7 patchlevel 249) (2010-07-28 6586) (Java
> HotSpot(TM) Client VM 1.6.0_21) [x86-java]
> 
> Here's my development step:
> 1. Create a 'data' directory under 'public', use to upload image
> 2. In my code, the upload directory write as 'upload_directory =
> "#{Rails.root}/public/data"', Here's the directory structure:
> 2010-10-19_091642.png

The list strips embedded & attached images.

Why not specify a different variable than #{Rails.root}?  Seems like
you're shooting yourself in the foot by using it.


p

> 3. Use warabler to package the whole rails project, Here's the directory
> structure now, you can see the data directory now is on the root of the war.
> 2010-10-19_091740.png
> 4. Then I start tomcat, the server can be startup successful. But when I
> try to upload the file, it goes error. This is because the Rails.root is
> point to WEB-INF now, and all directory under public moved to root of war.
> 
> I think there's something wrong with my strategy, but I don't know how
> to deal with it in rails. Or I need to set the upload directory to
> "#{Rails.root}/../data" when running under Tomcat? Is there anything
> better method? Thanks.
> 
> Here's my web.xml:
> <!DOCTYPE web-app PUBLIC
>   "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
>   "http://java.sun.com/dtd/web-app_2_3.dtd">
> <web-app>
> 
>   <context-param>
>     <param-name>rails.env</param-name>
>     <param-value>production</param-value>
>   </context-param>
> 
>   <context-param>
>     <param-name>public.root</param-name>
>     <param-value>/</param-value>
>   </context-param>
> 
> 
>   <filter>
>     <filter-name>RackFilter</filter-name>
>     <filter-class>org.jruby.rack.RackFilter</filter-class>
>   </filter>
>   <filter-mapping>
>     <filter-name>RackFilter</filter-name>
>     <url-pattern>/*</url-pattern>
>   </filter-mapping>
> 
>   <listener>
>   
>  <listener-class>org.jruby.rack.rails.RailsServletContextListener</listener-class>
>   </listener>
> 
> 
> </web-app>
> 
> Your faithfully, Kind regards.
> -- Ray
> 
> 
> On Tue, Oct 19, 2010 at 01:24, Pid <pid@pidster.com
> <mailto:pid@pidster.com>> wrote:
> 
>     On 18/10/2010 18:11, Ray Sun wrote:
>     > My basic requirement is upload and show image.
>     > I use rails on jruby and warble package the project as war on
>     windows. In
>     > rails, I set my upload directory as
>     '#{Rails.root}/public/data/users'. And
>     > it works on common rails light server like webrick. But after I
>     deployed to
>     > tomcat, the 'public' disappear.
> 
>     It disappears from the filing system, or from the path?
> 
>     > All the files under public went to the parent directory of WEB-INF.
> 
>     That would be the webapp directory.  Can you illustrate this with a full
>     path?
> 
>     Can you detail your exact Tomcat, Java & OS versions please?
>     How have you configured the Host in server.xml?
> 
>     > And after the server started, the rails function can't find the path.
>     > Then I tried to move my 'data' directory back to WEB-INF, but the url
>     > doesn't work.
> 
>     Why would you move it to WEB-INF?
> 
>     > I tried to create link in windows. But it still not works.
>     > Can anybody suggestion some work around to do this? Thanks.
> 
>     Uploading files to the webapp directory isn't a good strategy, because
>     the contents may be lost when you reload the application.
> 
>     Specifying a full path is more sensible.  You could then map that
>     directory into the application path's URL namespace, by defining a dummy
>     application which serves that path/directory.
> 
> 
>     p
> 
> 


Mime
View raw message