How to get a .cls file in a server directory and download it to the client side
I need to get a file in a directory and when clicking on the download button, this file will be downloaded on the client side.
<csp:class super="%CSP.Page,Relatorio.GeraCSV">
<body> <input type="button" value="Gera Relatório" onClick="#server(..serve())#"> </body>
ClassMethod serve() As %Status
{
set name = "C:\Users\gpemm\Desktop\myfile.csv"
#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(##class(%File).GetFilename(name), "UTF8")
set sc = ##class(%CSP.StreamServer).OnPage() } quit sc
}
https://community.intersystems.com/post/uploading-and-downloading-files-...
I've tried this something I saw in a post here, but I didn't succeed