- log into the Railo Web admin
- create a mapping for your archive
- edit the newly created mapping
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.
14 responses so far ↓
1 Gert Franz // Feb 19, 2008 at 9:41 PM
2 Brad B. // Feb 19, 2008 at 11:43 PM
3 Luis Majano // Feb 19, 2008 at 11:49 PM
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
5 Brad B. // Feb 20, 2008 at 12:57 AM
6 Gert Franz // Feb 20, 2008 at 10:41 AM
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
<CFVIDEO action="convert" source="myvideo.avi" target="myvideo.mp4" profile="iPhone">
The available actions are: convert, concat, cutimage and info
I will communicate the further attributes as soon as we release the Beta
2. CFVIDEOPLAYER
<CFVIDEOPLAYER video="myvideo.flv" allowfullscreen="true">
This tag displays a flash movie (like above) and allows the following things:
- customize the player
- allow fullscreen & 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
8 Serge // Apr 22, 2008 at 4:25 PM
For example, on production server I have railo mapping "/app, /WEB-INF/archive-app.ras" and it's trusted mapping. When I upload the new version of "archive-app.ras" 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
Can use only .ras archive without having "resource" 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
We'll look into it. Thanks for the hint.
Gert
11 Jason // Oct 21, 2009 at 10:54 PM
12 Gert Franz // Oct 26, 2009 at 8:30 AM
Gert
13 Matt // Jan 24, 2010 at 9:47 PM
I am running "Mango Blog" 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
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