![]() |
Chilkat HOME Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi DLL Go Java Node.js Objective-C PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(DataFlex) Box.com Download Binary File to MemorySee more Box ExamplesRetrieves the actual data of the file into a memory (not to a local file).
Use ChilkatAx-win32.pkg Procedure Test Boolean iSuccess Handle hoHttp Variant vBd Handle hoBd Integer iStatusCode String sTemp1 Integer iTemp1 Move False To iSuccess // This requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. Get Create (RefClass(cComChilkatHttp)) To hoHttp If (Not(IsComObjectCreated(hoHttp))) Begin Send CreateComObject of hoHttp End Set ComKeepResponseBody Of hoHttp To True // Provide a previously obtained OAuth2 access token. // See Get Box OAuth2 Access Token. Set ComAuthToken Of hoHttp To "BOX_ACCESS_TOKEN" Set ComFollowRedirects Of hoHttp To True // The file is specified by the file ID. // In this case, we're downloading a file with FILE_ID = 283371752129. // The general form of the URL for downloading is: https://api.box.com/2.0/files/FILE_ID/content Get Create (RefClass(cComChilkatBinData)) To hoBd If (Not(IsComObjectCreated(hoBd))) Begin Send CreateComObject of hoBd End Get pvComObject of hoBd to vBd Get ComDownloadBd Of hoHttp "https://api.box.com/2.0/files/283371752129/content" vBd To iSuccess Get ComLastStatus Of hoHttp To iStatusCode If (iSuccess = False) Begin If (iStatusCode = 0) Begin // Unable to either send the request or get the response. Get ComLastErrorText Of hoHttp To sTemp1 Showln sTemp1 End Else Begin // We got a response, but the status code was not in the 200s Showln "Response status code: " iStatusCode // Examine the response body. Showln "Response body:" Get ComLastResponseBody Of hoHttp To sTemp1 Showln sTemp1 End Showln "Download failed." End Else Begin Showln "Downloaded tigers.jpeg into an object holding the binary data." Get ComNumBytes Of hoBd To iTemp1 Showln "Number of bytes: " iTemp1 End End_Procedure |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.