Last active
December 11, 2020 20:06
-
-
Save timcunningham/abff45f78afbe5925711f033b92c4275 to your computer and use it in GitHub Desktop.
docfetcher
This file contains 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
<cfscript> | |
param name="url.document" default=""; | |
param name="statusText" default=""; | |
// Get document path. Replace backslashes in url.document with forward slashes for OS consistency | |
documentPath = settings.batchDirectory & "/" & url.document.replace("\", "/", "all"); | |
// Respond with 404 if the document does not exist on disk | |
if (! url.document.len() || ! fileExists(documentPath)) { | |
response.statusCode = 404; | |
response.statusText = "NotFound"; | |
response.body.error = "File not found"; | |
} | |
// Otherwise process the document for response | |
else { | |
document = fileRead(documentPath); | |
response.statusCode = 200; | |
} | |
// Echo back the success and file content | |
response.body.success = fileExists(documentPath) ? true : false; | |
response.body.html =fileExists(documentPath) ? document : ""; | |
response.body.file = ""; | |
</cfscript> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment