-
-
Save amendoncabh/6b3a48cf83b0115dad23c2d3f2c9c730 to your computer and use it in GitHub Desktop.
ADVPL Function to download a file using SOAP or REST api
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
//--------------------------------------------------------------------- | |
/*/{Protheus.doc} Download | |
Download de arquivo via HTTP (SOAP, REST) | |
@since 14/03/2016 | |
@version P12 | |
@return logic | |
/*/ | |
//--------------------------------------------------------------------- | |
Static Function Download( oWebService, cPath, cFileName ) | |
Local xBytes := ReadBytes( cPath ) | |
If Nil == xBytes .Or. 0 <> FError() | |
Return .F. | |
EndIf | |
oWebService:SetContentType( 'application/octet-stream' ) | |
oWebService:SetHeader( 'Content-Disposition', 'attachment; filename=' + cFileName ) | |
oWebService:SetHeader( 'Pragma', 'no-cache' ) | |
oWebService:SetResponse( xBytes ) | |
Return .T. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment