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) Initiate Resumable Upload SessionSee more Google Cloud Storage ExamplesInitiate a Google Cloud Storage resumable upload session.. For more information, see https://cloud.google.com/storage/docs/performing-resumable-uploads
Use ChilkatAx-win32.pkg Procedure Test Handle hoHttp Handle hoJsonToken Boolean iSuccess Handle hoJsonMetaData String sUrl Variant vResp Handle hoResp Integer iStatusCode String sSessionUrl String sTemp1 Boolean bTemp1 // This example assumes 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 Get Create (RefClass(cComChilkatJsonObject)) To hoJsonToken If (Not(IsComObjectCreated(hoJsonToken))) Begin Send CreateComObject of hoJsonToken End Get ComLoadFile Of hoJsonToken "qa_data/tokens/googleCloudStorage.json" To iSuccess If (iSuccess = False) Begin Get ComLastErrorText Of hoJsonToken To sTemp1 Showln sTemp1 Procedure_Return End Get Create (RefClass(cComChilkatJsonObject)) To hoJsonMetaData If (Not(IsComObjectCreated(hoJsonMetaData))) Begin Send CreateComObject of hoJsonMetaData End Get ComUpdateString Of hoJsonMetaData "contentType" "image/jpeg" To iSuccess // Adds the "Authorization: Bearer <access_token>" header.. Get ComStringOf Of hoJsonToken "access_token" To sTemp1 Set ComAuthToken Of hoHttp To sTemp1 Get ComSetUrlVar Of hoHttp "bucket_name" "chilkat-bucket-b" To iSuccess Get ComSetUrlVar Of hoHttp "object_name" "penguins2.jpg" To iSuccess Move "https://storage.googleapis.com/upload/storage/v1/b/{$bucket_name}/o?uploadType=resumable&name={$object_name}" To sUrl Get ComEmit Of hoJsonMetaData To sTemp1 Get ComPText Of hoHttp "POST" sUrl sTemp1 "utf-8" "application/json" False False To vResp If (IsComObject(vResp)) Begin Get Create (RefClass(cComChilkatHttpResponse)) To hoResp Set pvComObject Of hoResp To vResp End Get ComLastMethodSuccess Of hoHttp To bTemp1 If (bTemp1 = False) Begin Get ComLastErrorText Of hoHttp To sTemp1 Showln sTemp1 Procedure_Return End Get ComStatusCode Of hoResp To iStatusCode Showln "response status code = " iStatusCode Move "" To sSessionUrl If (iStatusCode <> 200) Begin Get ComBodyStr Of hoResp To sTemp1 Showln sTemp1 End Else Begin // The session URL will be used to upload the file in chunks, in subsequent HTTP POSTs... Get ComGetHeaderField Of hoResp "Location" To sSessionUrl Showln "Session URL = " sSessionUrl End Send Destroy of hoResp End_Procedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.