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
(PowerBuilder) S3 Add Tags to an ObjectSee more Amazon S3 (new) ExamplesDemonstrates how to add one or more tags to an S3 object. For more information, see https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutObjectTagging.html
integer li_rc oleobject loo_Rest integer li_BTls integer li_Port integer li_BAutoReconnect integer li_Success oleobject loo_AuthAws oleobject loo_Xml oleobject loo_SbRequestBody oleobject loo_SbResponse // This example requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. loo_Rest = create oleobject li_rc = loo_Rest.ConnectToNewObject("Chilkat_9_5_0.Rest") if li_rc < 0 then destroy loo_Rest MessageBox("Error","Connecting to COM object failed") return end if // Connect to the Amazon AWS REST server in the desired region. // (for us-east-1, we use "s3.amazonaws.com", but for another region, such as us-west-2, we would use "s3-us-west-2.amazonaws.com") li_BTls = 1 li_Port = 443 li_BAutoReconnect = 1 li_Success = loo_Rest.Connect("s3.amazonaws.com",li_Port,li_BTls,li_BAutoReconnect) // Provide AWS credentials. loo_AuthAws = create oleobject li_rc = loo_AuthAws.ConnectToNewObject("Chilkat_9_5_0.AuthAws") loo_AuthAws.AccessKey = "AWS_ACCESS_KEY" loo_AuthAws.SecretKey = "AWS_SECRET_KEY" loo_AuthAws.ServiceName = "s3" loo_AuthAws.Region = "us-east-1" loo_Rest.SetAuthAws(loo_AuthAws) // Set the bucket name via the HOST header. // In this case, the bucket name is "chilkat100". // Note that the Host header should use "bucketName.s3.amazonaws.com", not "bucketName.s3-us-east-1.amazonaws.com" // The same applies to aother regions. The Host header should simply be <bucketName>.s3.amazonaws.com regardless of the region. loo_Rest.Host = "chilkat100.s3.amazonaws.com" loo_Xml = create oleobject li_rc = loo_Xml.ConnectToNewObject("Chilkat_9_5_0.Xml") loo_Xml.Tag = "Tagging" loo_Xml.UpdateChildContent("TagSet|Tag|Key","plant") loo_Xml.UpdateChildContent("TagSet|Tag|Value","chili pepper") loo_SbRequestBody = create oleobject li_rc = loo_SbRequestBody.ConnectToNewObject("Chilkat_9_5_0.StringBuilder") loo_Xml.GetXmlSb(loo_SbRequestBody) // It is important to add the terminating "=" after the "?tagging". loo_SbResponse = create oleobject li_rc = loo_SbResponse.ConnectToNewObject("Chilkat_9_5_0.StringBuilder") li_Success = loo_Rest.FullRequestSb("PUT","/chiliPepper.gif?tagging=",loo_SbRequestBody,loo_SbResponse) if li_Success = 0 then Write-Debug loo_Rest.LastErrorText destroy loo_Rest destroy loo_AuthAws destroy loo_Xml destroy loo_SbRequestBody destroy loo_SbResponse return end if Write-Debug "Response status code: " + string(loo_Rest.ResponseStatusCode) // When successful, the S3 Storage service will respond with a 200 response code, // with an XML body. if loo_Rest.ResponseStatusCode <> 200 then // Examine the request/response to see what happened. Write-Debug "response status code = " + string(loo_Rest.ResponseStatusCode) Write-Debug "response status text = " + loo_Rest.ResponseStatusText Write-Debug "response header: " + loo_Rest.ResponseHeader Write-Debug "response body: " + loo_SbResponse.GetAsString() Write-Debug "---" Write-Debug "LastRequestStartLine: " + loo_Rest.LastRequestStartLine Write-Debug "LastRequestHeader: " + loo_Rest.LastRequestHeader end if Write-Debug loo_SbResponse.GetAsString() Write-Debug "Success." destroy loo_Rest destroy loo_AuthAws destroy loo_Xml destroy loo_SbRequestBody destroy loo_SbResponse |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.