Last active
April 6, 2021 12:12
-
-
Save vitorebatista/bfcbf02eb68766f7e01543bc7e3f0f48 to your computer and use it in GitHub Desktop.
ADVPL Function to download a file using SOAP or REST api
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
//--------------------------------------------------------------------- | |
/*/{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