Creating Railo archives

February 19, 2008 · By Gert Franz · 14 Comments

I have been asked several times to describe how to create and use a Railo archive. This entry also describes how to include images inside an archive.This is the procedure of how to create an Archive. The creation of an archive is quite simple. Just procede the following steps:
  1. log into the Railo Web admin
  2. create a mapping for your archive
  3. edit the newly created mapping
At the bottom of the page you can find the buttons to create archives. There are two actions you can execute here. You can either create and download the archive, or you can create the archive and assign it to the created mapping. So creating an archive is quite easy.
Images from the archive
If you create an archive you might want to include images in this archive, since you might only want to ship the archive containing all the images of your application as well. Now how to do that? The answer is a little tricky since only Railo knows how to handle archives. In order for Railo to get involved, a filename must end on .cfm or .cfc. Simply renaming an image from eg. image.jpg to image.jpg.cfm won't help since Railo would output the file without interpreting it as of a mime type JPG etc. The only thing you would see is:
ÿØÿá?æExif??II*?.???.?...?.???.???1..?.???J???2..?.???f???áÂ@Ö.¹ÁãnYç#F:w,ø|õ .3˜..‰.ZÁÎ,êx.Ê.?}%7¾"2§Å.·ËY×â.öMIPj*î_7~7ôúÊ&ó.ÇÊ*·Ÿ*
¤--6)ú?XwâPm.>¡Öû|.9·7Jø.U¸Æm.'T?.1Lê/ry>± ™Ç€¥¢ý†Óm-Ž.Ò.mÉ'œp.d%Æ .o•...Á! YX?ÿÙ

So what to do?
The answer is to create a valid .cfm file (CFML syntax) that returns the image as content. Therfore you have to convert an image like follows: <cffile action="readbinary" file="/archive/image.jpg" variable="data">
<!--- create the content of the file --->
<cfoutput><cfsavecontent variable="content">
#chr(60)#cfsetting showdebugoutput="no">#chr(60)#cfcontent type="image/jpg" content="###serialize(data)###">
</cfsavecontent></cfoutput>
<!--- write the new image file --->
<cffile action="write" addnewline="no" file="/archive/image.cfm" output="#content#" fixnewline="no">
Now the created file might contain something like this: <cfsetting showdebugoutput="no">
<cfcontent type="image/jpg" content="#evaluateJava('rO0ABXVyAAJbQqzABuR0lGODlhFQAEALMAAGxaU2BQS3NfWWBQSlNFQGFQS1JEQHJDs=')#">
These .cfm files can be compiled correctly and therefore converted into java bytecode. In this way images can be included within a railo archive. You can use the code below in order to convert your images into valid .cfm files: <cfdirectory directory="/archive/img" action="list" name="imgs">
<cfset bins=struct()>
<cfloop query="imgs">
<cfif findnoCase(".gif",imgs.name) or findnoCase(".swf",imgs.name) or findnoCase(".jpg",imgs.name)>
<cfset sExt = ListLast(imgs.name, ".")>
<cffile action="readbinary" file="/archive/img/#imgs.name#" variable="data">
<cfoutput><cfsavecontent variable="content"><!---
--->
#chr(60)#cfsetting showdebugoutput="no">#chr(60)#cfcontent type="image/#sExt#" content="###serialize(data)###"><!---
---></cfsavecontent></cfoutput>
<cfdump eval="expandPath('/archive/img_cfm/#imgs.name#.cfm')">
<cffile action="write" addnewline="no" file="/archive/img_cfm/#imgs.name#.cfm" output="#content#" fixnewline="no">
</cfif>
</cfloop>

Just click on the play button in order to see how to create a Railo archive.

You can download the source of the application here.

Tags: Features · Performance · Railo 1.1 · Railo 2.0

14 responses so far ↓

  • 1 Gert Franz // Feb 19, 2008 at 9:41 PM

    BTW: The video conversion and the player are part of Railo 2.1
  • 2 Brad B. // Feb 19, 2008 at 11:43 PM

    The video player looks impressive. Will you elaborate on cfvideo soon? Can you hint on what attributes it requires?
  • 3 Luis Majano // Feb 19, 2008 at 11:49 PM

    Hi Gert,
    Thanks for the instructional video!! Much better than reading text. I will give it a shot and try to finally start embedding the Dashboard as a Railo Archive.

    By the way, 2.0.0.034 really flies, man!! Great job!!
  • 4 Luis Majano // Feb 20, 2008 at 12:19 AM

    Also,what do you use to capture the screen? Any recommendations?
  • 5 Brad B. // Feb 20, 2008 at 12:57 AM

    Luis, on Windows/Mac Jing works well for being free, or Camtasia.
  • 6 Gert Franz // Feb 20, 2008 at 10:41 AM

    @Luis:
    I am using HyperCam 2, which I personally really like a lot. After that I have used CFVideo in order to convert the video from AVI to FLV.
    @Brad :
    Railo 2.1 will introduce 3 new Tags.
    1. CFVIDEO for manipulating videos, just like CFIMAGE does with images
    &lt;CFVIDEO action=&quot;convert&quot; source=&quot;myvideo.avi&quot; target=&quot;myvideo.mp4&quot; profile=&quot;iPhone&quot;&gt;
    The available actions are: convert, concat, cutimage and info
    I will communicate the further attributes as soon as we release the Beta
    2. CFVIDEOPLAYER
    &lt;CFVIDEOPLAYER video=&quot;myvideo.flv&quot; allowfullscreen=&quot;true&quot;&gt;
    This tag displays a flash movie (like above) and allows the following things:
    - customize the player
    - allow fullscreen &amp; download
    - preview images
    - playlists
    - many more
    3. CFVIDEOPLAYERPARAM
    - This tag customizes the CFVIDEOPLAYER.
    I will write about the video functionality in one of the next blogs. Blueriver (www.blueriver.com) has helped a lot in defining the functionality of the tags.
  • 7 Brad B. // Feb 20, 2008 at 12:05 PM

    CFVideo etc.. looks like a very neat tag. I've forwarded this to some colleagues. Railo is epic in many regards imo, and the team is doing amazing work - thanks so much!
  • 8 Serge // Apr 22, 2008 at 4:25 PM

    Is there an option to reload railo archive quickly?
    For example, on production server I have railo mapping &quot;/app, /WEB-INF/archive-app.ras&quot; and it's trusted mapping. When I upload the new version of &quot;archive-app.ras&quot; I see no changes and to make changes appear I can restart server or delete mapping and create a new one. If there is a magic button that would do the second?
  • 9 Serge // Aug 6, 2009 at 7:00 PM

    Hello Gert,
    Can use only .ras archive without having &quot;resource&quot; defined?
    I compile .ras-archive locally, but when I try to use on the web-server it fails.
    My configuration is:
    Virtual: /spirit
    Archive: /var/www/archive-spirit.ras (it's not red)
    Primary: Archive
    It seems to me
  • 10 Gert Franz // Aug 6, 2009 at 7:47 PM

    Well then point it to an empty directory. That should help.
    We'll look into it. Thanks for the hint.

    Gert
  • 11 Jason // Oct 21, 2009 at 10:54 PM

    Once you create a mapping to an archive can you then replace the archive with another archive by simply copying a ras file over the existing one? For instance if I were to create an archive and deploy it to different web servers for production usage could I then make updates to the development version archive it and replace the production copies with the new ras file?
  • 12 Gert Franz // Oct 26, 2009 at 8:30 AM

    Well you can do it but you need to unassign it from the mapping first (Do that with the tag CFADMIN, then copy over the archive and then reassign the new file.

    Gert
  • 13 Matt // Jan 24, 2010 at 9:47 PM

    What does this do for performance?

    I am running &quot;Mango Blog&quot; under a /blog/ folder which is very slow and want the whole thing to be cached.

    Hope you can help.
  • 14 Gert Franz // Jan 25, 2010 at 11:24 AM

    Matt,

    the performance impact is around 5-15% I would say. BUT this is for loading pages for the first time. Databases don't get faster because of this. There should be several other things you could use. Have a look at CFCache or Cached queries or tune the memory of the server.

    If you need help, just join the mailing list:
    http://groups.google.com/group/railo

    Gert Franz
    Railo Technologies

Leave a Comment

Leave this field empty: