3 Replies Latest reply on Jun 9, 2015 4:44 PM by D P

    Where to store static contents like images on Wildfly 8.2.0

    D P Apprentice

      Our application refer images from external file system on server. What is the best practices to store images on Wildfly server.

       

      Where should I store it and refer it in code.

       

      Thanks,

        • 2. Re: Where to store static contents like images on Wildfly 8.2.0
          Jay SenSharma Master

          Hello DP,

           

              You can try the following,  Add a new Handler inside the "undertow" subsystem and then add that handler reference to the "Host" tag present in the same undertow subsystem:

           

               <subsystem xmlns="urn:jboss:domain:undertow:1.2">
                      <buffer-cache name="default"/>
                      <server name="default-server">
                          <http-listener name="default" socket-binding="http"/>
                          <host name="default-host" alias="localhost">
                              <location name="/" handler="welcome-content"/>
                              <location name="/images" handler="PicturesDir"/>
                              <filter-ref name="server-header"/>
                              <filter-ref name="x-powered-by-header"/>
                          </host>
                      </server>
                      <servlet-container name="default">
                          <jsp-config/>
                          <websockets/>
                      </servlet-container>
                      <handlers>
                          <file name="welcome-content" path="${jboss.home.dir}/welcome-content"/>
                          <file name="PicturesDir" path="/PATH/TO/Pictures" directory-listing="true"/>
                      </handlers>
                      <filters>
                          <response-header name="server-header" header-name="Server" header-value="WildFly/8"/>
                          <response-header name="x-powered-by-header" header-name="X-Powered-By" header-value="Undertow/1"/>
                      </filters>
                  </subsystem>
          

           

          Notice the following lines which are added to the default configuration of the undertow::

           

          <file name="PicturesDir" path="/PATH/TO/Pictures" directory-listing="true"/>
          AND
          <location name="/images" handler="PicturesDir"/>
          

           

          Restart Wildfly and then access the URL:

           

          http://localhost:8080/images/

          1 of 1 people found this helpful
          • 3. Re: Where to store static contents like images on Wildfly 8.2.0
            D P Apprentice

            Thanks Jay Kumar, It's working with above steps.

             

            Thanks,

            Dhaval