Skip to content

Instantly share code, notes, and snippets.

@ejhayes
Created February 22, 2011 21:10
Show Gist options
  • Select an option

  • Save ejhayes/839396 to your computer and use it in GitHub Desktop.

Select an option

Save ejhayes/839396 to your computer and use it in GitHub Desktop.
Create a CFC from a binary object (and even without the cfc extension).
component {
this.name = "";
// you may or may not be able to do this part, but
// the ram needs to be mapped accordingly or this
// will not work with createObject since it expects
// dot notation!
this.mappings[ "/ram" ] = "ram://";
}
<!--- This example will load an arbitrary CFC --->
<cfscript>
// read your file here
f = FileReadBinary("FILEPATH HERE");
// write the file to memory (mapped earlier)
FileWrite("/ram/YOURCFCNAME.cfc");
// now we can use it
b = createObject("ram.YOURCFCNAME");
// and remove the file from ram
FileDelete("/ram/YOURCFCNAME.cfc");
// and finally we have our cfc object
WriteDump(b);
</cfscript>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment