Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(DataFlex) REST Download Binary File to MemorySee more REST ExamplesDownload a binary file to a Chilkat BinData object.
Use ChilkatAx-9.5.0-win32.pkg Procedure Test Handle hoRest Boolean iSuccess String sPathPartOfUrl String sDomain Boolean iBTls Integer iPort Boolean iBAutoReconnect Boolean iSuccess Variant vBd Handle hoBd Handle hoSbErrorText String sTemp1 Integer iTemp1 // This requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. Get Create (RefClass(cComChilkatRest)) To hoRest If (Not(IsComObjectCreated(hoRest))) Begin Send CreateComObject of hoRest End // We're going to download a sample MS-Word doc file. // The URLs of our MS-Word sample documents are: // https://www.chilkatdownload.com/sample_data/sample.doc // https://www.chilkatdownload.com/sample_data/sample.docx Move "/sample_data/sample.doc" To sPathPartOfUrl Move "chilkatdownload.com" To sDomain Move True To iBTls Move 443 To iPort Move True To iBAutoReconnect Get ComConnect Of hoRest sDomain iPort iBTls iBAutoReconnect To iSuccess If (iSuccess <> True) Begin Get ComLastErrorText Of hoRest To sTemp1 Showln sTemp1 Procedure_Return End Get Create (RefClass(cComChilkatBinData)) To hoBd If (Not(IsComObjectCreated(hoBd))) Begin Send CreateComObject of hoBd End Get pvComObject of hoBd to vBd Get ComFullRequestNoBodyBd Of hoRest "GET" sPathPartOfUrl vBd To iSuccess If (iSuccess <> True) Begin Get ComLastErrorText Of hoRest To sTemp1 Showln sTemp1 Procedure_Return End // A 200 response is expected for actual success. // If we don't get a 200 response, then the response body was not actually // the file data, but it was text containing error information. Get ComResponseStatusCode Of hoRest To iTemp1 If (iTemp1 <> 200) Begin Get Create (RefClass(cComChilkatStringBuilder)) To hoSbErrorText If (Not(IsComObjectCreated(hoSbErrorText))) Begin Send CreateComObject of hoSbErrorText End Get pvComObject of hoBd to vBd Get ComAppendBd Of hoSbErrorText vBd "utf-8" 0 0 To iSuccess Get ComGetAsString Of hoSbErrorText To sTemp1 Showln sTemp1 Showln "-- Failed." Procedure_Return End // Save to a local file. // Change the file path based on your operating system or needs... Get ComWriteFile Of hoBd "c:/temp/qa_output/sample.doc" To iSuccess If (iSuccess <> True) Begin Showln "Failed to save to local file." Procedure_Return End Showln "REST Download of MS-Word File was successful." End_Procedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.