0

ColdFusion in odd places - using the directory watcher on my desktop

ColdFusion, InstantSpot, Tips and Tricks

Since recently installling yet another distro on my laptop, I was unable to get the FTP functionality of my webcam software (Camorama) to work properly. The program will save snapshots locally, but bombs on transfer. Rather than troubleshoot it to death, I decided to whip out a quick and dirty ColdFusion directory watcher event gateway and have it watch for updated images, and then push them to my webserver via FTP.

For anyone interested in this non-earth shattering bit of code, here it is. First I created a config file:

WebcamWatcher.cfg

# The directory we want to watch. 
directory=/home/dshuck/Webcam_Pictures

# Do we want to recurse the directories?
recurse=no

# miliseconds between checks
interval=6000

# The comma separated list of extensions to match.
extensions=*

# component method for change events
changeFunction=onChange

# component method for add events
addFunction=onAdd

# no delete events for now
deleteFunction= 

Now to create the methods in our WebcamWatcher.cfc. In short, either a changed file or an added file will trigger the putImage function which first creates the FTP connection, changes directories to my webcam directory, then pushes the file to the server. Here is the code:

WebcamWatcher.cfc

<cfcomponent output="false">
	<cffunction name="onAdd" output="false">
		<cfargument name="CFEvent" type="struct" required="yes">
		<cfset var Data=CFEvent.data />
	  	<cflog file="DirectoryWatcher" application="No" 
	     	text=" ACTION: #data.type#;  FILE: #data.filename#;  calling putImage()" />
		<cfset putImage() />
	</cffunction>
	

	<cffunction name="onChange" output="false">
	  	<cfargument name="CFEvent" type="struct" required="yes">
	  	<cfset var data=CFEvent.data>
	  	<cflog file="DirectoryWatcher" application="No" 
	      text=" ACTION: #data.type#;  FILE: #data.filename#; TIME: #timeFormat(data.lastmodified)# calling putImage();" />
		<cfset putImage() />
	</cffunction>

	<cffunction name="putImage" access="private" output="false" returntype="void">
		<cfftp action = "open"
	   		username = "joeuser"
	  		connection = "MyConnection"
	   		password = "mycoolpassword"
	   		server = "www.mywebserver.com"
	   		stopOnError = "true" />
		
		<cfif cfftp.Succeeded>
			<cfftp 
				connection="MyConnection" 
				action="changedir" 
				directory="htdocs/mywebcamdirectory" />
			
			<cfif cfftp.Succeeded>
				<cfftp 
					connection = "MyConnection"
					action = "putFile" 
					name = "uploadFile" 
					transferMode = "binary" 
					localFile = "/home/dshuck/Webcam_Pictures/webcam.jpeg" 
					remoteFile = "DaveWebcam.jpg" />
			</cfif>
	
		</cfif>
		<cflog file="DirectoryWatcher" application="false" text="file push to webserver...#cfftp.Succeeded#" />
	</cffunction>
</cfcomponent>

So, now the internet can yet again be graced with my "almost live" presence. I can almost hear the selective sigh of relief.

I have to consider this to be a somewhat odd place for ColdFusion and it got me thinking... What kinds of odd places do you or have you used ColdFusion?

+1

We're on the ColdFusion Weekly!

ColdFusion, InstantSpot

The latest version of the ColdFusion Weekly podcast was released yesterday.  Matt and Peter were kind enough to have Aaron and I on to talk about InstantSpot.  This was actually our second time to have this opportunity, although we had *much* more to talk about given our experiences over the last 14 months since the previous visit! 

We covered a lot of areas from how it all came about in the first place, to some of our trials and tribulations rolling out the latest release and all points in between.   If you would like to hear some of our experiences and the technology behind our network, I urge you to check it out.

Download Icon Download Version 3.02

 

+2

Yes ColdFusion fans... we *are* a ColdFusion site!

ColdFusion, InstantSpot

I don't know how pervasive this point of confusion is, but today a regular face in the ColdFusion community was making some remarks in this comment thread and further on his InstantSpot site that InstantSpot is not a ColdFusion-based application, with the insinuation that he won't support our efforts because of this.

Just to be clear, no matter whether or not you actually see ".cfm" in the URL, we are running InstantSpot on Adobe ColdFusion 8, using Mach-II 1.6, ColdSpring and other community tools. We are strong advocates for ColdFusion, work with our local ColdFusion User Group, try to be evangelists for it wherever we can, and we will continue to do so.

+2

5 InstantSpot invitations

InstantSpot

If anyone is interested in creating an InstantSpot blog, we are opening up 5 new Spots today and would love to see some more ColdFusion peeps! Enter your invitation code on the main page. As soon as someone uses a code it's gone:

  • k7Nh92Sw
  • GEAGGH7B
  • rs4DPq9a
  • OUWKCEgG
  • lepvefKv

Get 'em while their hot! :)

EDIT: All gone!
+2

New pseudo-steampunk theme on my blog

InstantSpot, Blog

I have a new addiction playing with the style editor for my blog... I hate to call this a steampunk theme, simply for the inevitable flow of hardcore steampunk people coming here and telling me about how I don't know what steampunk is... so let's settle for pseudo steampunk shall we? 

Regardless, at my current rate I will change it again in a few days anyway! :)

I was also told this week that I look a lot different in my picture than I do in person.  I decided to add a headshot that says "Hey look... Dave was up all night coding again."  I think it is fairly true to life.

+1

Publishing blog entries with ScribeFire using XMLRPC API

InstantSpot, Tips and Tricks

On the most recent release of InstantSpot, we added in XMLRPC support so that blog administration can happen anywhere, using any client that supports XMLRPC. We are thinking it might be fun to create an AIR app for this purpose down the line (or better yet... someone else! hint...hint...), but until that time, there are a variety of clients that can be used, since we followed the MetaWeblog API standards.

I am actually trying this out for the first time on our live instance with this blog entry by using a *sweet* Firefox plugin called ScribeFire. Considering that we haven't really published this ability, I thought it might make sense to do a walk through of setting it up and using it.

First, let's walk through the ScribeFire Account Wizard. One you have installed the ScribeFire plugin (available here), click on the little text pad icon in the bottom corner of your browser window and start the Account Wizard. You should see a window that looks like the one below. Choose "Manually Configure" and continue.



You will then be presented with a number of options of various inferior blogging services. Choose "Custom Blog" and continue.



On the screen you see below, choose "MetaWeblog API" and enter this URL into the Server API URL input box: http://www.instantspot.com/gospot/remote.metaweblogAPI
Leave "Advanced Settings" unchecked and continue.



On the following screen you will be prompted for your username and password. Since the new release of InstantSpot, your email address is now used as your username.



That's it! If you did this correctly you should see your blog listed in the following screen like this:


Now, you should see a list of your categories (labeled in the interface as "tags"), blogposts, and in the future, saved "Notes" which are drafts stored locally by ScribeFire to the right of the ScribeFire window like this:


From here, the interface is pretty simple. One thing that is noteworthy is that we even support the ability for you to upload and insert images through ScribeFire. When you click on the image icon on the editor, you will see a window that looks like this:



Choose "Image Upload", then after browsing to your file, select "Upload Via API".



When it completes you will see the following window. Choose "Insert Image" and you will see your image inserted into your text.



Now you can start posting away to your heart's content!

Powered by ScribeFire.


Search