Last active
March 30, 2017 18:04
-
-
Save nikitaeverywhere/1b43e647f158136564560b02a80880b0 to your computer and use it in GitHub Desktop.
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
/// Original: https://github.com/eduard93/Utils/blob/master/Utils/REST.cls.xml | |
Class Utils.REST Extends %CSP.REST | |
{ | |
XData UrlMap | |
{ | |
<Routes> | |
<Route Url="/file" Method="GET" Call="GET"/> | |
</Routes> | |
} | |
ClassMethod GET() | |
{ | |
set name = "Z:\icons.woff" | |
quit ..serve(name) | |
} | |
ClassMethod serve(name) As %Status | |
{ | |
#dim sc As %Status = $$$OK | |
#dim %response As %CSP.Response | |
kill %request.Data | |
set %request.Data("STREAMOID",1)= ##class(%CSP.StreamServer).Encrypt(##class(%CSP.StreamServer).GetOidForFile(name)) | |
if ##class(%CSP.StreamServer).OnPreHTTP() { | |
set %response.Headers("Content-Disposition")="attachment; filename*=UTF-8''" _ ##class(%CSP.Page).EscapeURL(name, "UTF8") | |
set sc = ##class(%CSP.StreamServer).OnPage() | |
} | |
quit sc | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment