Created
February 22, 2011 21:10
-
-
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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!--- 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