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) Azure Storage: Set Blob Service PropertiesAzure Storage Blob Service REST API: Sample code to set a blob's service properties.
Use ChilkatAx-win32.pkg Procedure Test Handle hoRest Boolean iBTls Integer iPort Boolean iBAutoReconnect Boolean iSuccess Variant vAzAuth Handle hoAzAuth Handle hoXml Variant vXLogging Handle hoXLogging Variant vXRetension Handle hoXRetension String sResponseStr String sTemp1 Integer iTemp1 Boolean bTemp1 // Azure Blob Service Example: Set Blob Service Properties // See also: https://msdn.microsoft.com/en-us/library/azure/hh452235.aspx // This example 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 // Connect to the Azure Storage Blob Service Move True To iBTls Move 443 To iPort Move True To iBAutoReconnect // In this example, the storage account name is "chilkat". Get ComConnect Of hoRest "chilkat.blob.core.windows.net" iPort iBTls iBAutoReconnect To iSuccess If (iSuccess <> True) Begin Get ComLastErrorText Of hoRest To sTemp1 Showln sTemp1 Procedure_Return End // Provide Azure Cloud credentials for the REST call. Get Create (RefClass(cComChilkatAuthAzureStorage)) To hoAzAuth If (Not(IsComObjectCreated(hoAzAuth))) Begin Send CreateComObject of hoAzAuth End Set ComAccessKey Of hoAzAuth To "AZURE_ACCESS_KEY" // The account name used here should match the 1st part of the domain passed in the call to Connect (above). Set ComAccount Of hoAzAuth To "chilkat" Set ComScheme Of hoAzAuth To "SharedKey" Set ComService Of hoAzAuth To "Blob" // This causes the "x-ms-version: 2021-08-06" header to be automatically added. Set ComXMsVersion Of hoAzAuth To "2021-08-06" Get pvComObject of hoAzAuth to vAzAuth Get ComSetAuthAzureStorage Of hoRest vAzAuth To iSuccess // Note: The application does not need to explicitly set the following // headers: x-ms-date, Authorization. These headers // are automatically set by Chilkat. // This example will set logging properties. The XML body of the request // will look like this: // <?xml version="1.0" encoding="utf-8"?> // <StorageServiceProperties> // <Logging> // <Version>version-number</Version> // <Delete>true|false</Delete> // <Read>true|false</Read> // <Write>true|false</Write> // <RetentionPolicy> // <Enabled>true|false</Enabled> // <Days>number-of-days</Days> // </RetentionPolicy> // </Logging> // Build the request: Get Create (RefClass(cComChilkatXml)) To hoXml If (Not(IsComObjectCreated(hoXml))) Begin Send CreateComObject of hoXml End Set ComTag Of hoXml To "StorageServiceProperties" Get ComNewChild Of hoXml "Logging" "" To vXLogging If (IsComObject(vXLogging)) Begin Get Create (RefClass(cComChilkatXml)) To hoXLogging Set pvComObject Of hoXLogging To vXLogging End Send ComNewChild2 To hoXLogging "Version" "1.0" Send ComNewChild2 To hoXLogging "Delete" "true" Send ComNewChild2 To hoXLogging "Read" "true" Send ComNewChild2 To hoXLogging "Write" "true" Get ComNewChild Of hoXLogging "RetentionPolicy" "" To vXRetension If (IsComObject(vXRetension)) Begin Get Create (RefClass(cComChilkatXml)) To hoXRetension Set pvComObject Of hoXRetension To vXRetension End Send ComNewChild2 To hoXRetension "Enabled" "true" Send ComNewChild2 To hoXRetension "Days" "7" Send Destroy of hoXRetension Send Destroy of hoXLogging // The expected response is a 202 response status code with no response body. Get ComGetXml Of hoXml To sTemp1 Get ComFullRequestString Of hoRest "PUT" "/?restype=service&comp=properties" sTemp1 To sResponseStr Get ComLastMethodSuccess Of hoRest To bTemp1 If (bTemp1 <> True) Begin Get ComLastErrorText Of hoRest To sTemp1 Showln sTemp1 Procedure_Return End // When successful, the Azure Storage service will respond with a 202 response code, // with no response body. Get ComResponseStatusCode Of hoRest To iTemp1 If (iTemp1 <> 202) Begin // Examine the request/response to see what happened. Get ComResponseStatusCode Of hoRest To iTemp1 Showln "response status code = " iTemp1 Get ComResponseStatusText Of hoRest To sTemp1 Showln "response status text = " sTemp1 Get ComResponseHeader Of hoRest To sTemp1 Showln "response header: " sTemp1 Showln "response body (if any): " sResponseStr Showln "---" Get ComLastRequestStartLine Of hoRest To sTemp1 Showln "LastRequestStartLine: " sTemp1 Get ComLastRequestHeader Of hoRest To sTemp1 Showln "LastRequestHeader: " sTemp1 Procedure_Return End Showln "Success: Blob service properties updated!" End_Procedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.