S3: Connect to an S3-Compatible Provider
See more S3 - HTTP Examples
Uses Chilkat.Http with Amazon S3 general purpose buckets and Signature Version 4. These examples do not cover directory buckets/S3 Express, access-point ARNs, Outposts, or other specialized endpoints. They target the commercial AWS partition; other partitions need their documented endpoint suffix.
Load private qa_data/aws/s3-compatible.json containing nonempty string fields access_key and secret_key, plus session_token for temporary credentials. Prefer short-lived role credentials. These samples do not discover AWS profiles or refresh credentials. Set the bucket's actual region and replace sample bucket names and object keys. TLS certificate verification is explicitly enabled. Keep detailed HTTP diagnostics private because they can contain credentials or presigned URLs.
Uses separate provider credentials in qa_data/aws/s3-compatible.json; do not send AWS credentials to an unrelated endpoint. Replace the reserved example hostname and signing region with the provider's documented values. The endpoint is a hostname without an https:// prefix. SigV4 remains the default and TLS verification stays enabled.
S3 compatibility is not identical to AWS S3. Verify authentication, addressing style, supported headers, pagination, versioning, checksums, and error semantics with the provider. This example calls the unpaginated bucket helper and displays the validated XML response; it does not claim that every provider has the same quota or pagination behavior as AWS.
Chilkat AutoIt Downloads
Local $bSuccess = False
$oStringCompare = ObjCreate("Chilkat.StringBuilder")
; This example requires the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.
; Load private credentials; never put access keys or session tokens in source.
$oCredentials = ObjCreate("Chilkat.JsonObject")
$oCredentials.Strict = True
$bSuccess = $oCredentials.LoadFile("qa_data/aws/s3-compatible.json")
If ($bSuccess <> True) Then
ConsoleWrite("Could not load private S3 credentials." & @CRLF)
Exit
EndIf
$oStringCompare.SetString($oCredentials.StringOf("access_key"))
Local $bStringMatch1 = $oStringCompare.ContentsEqual("",True)
If (($oCredentials.JsonTypeOf("access_key") <> 1) Or ($bStringMatch1 = True)) Then
ConsoleWrite("Missing or invalid access_key." & @CRLF)
Exit
EndIf
$oStringCompare.SetString($oCredentials.StringOf("secret_key"))
Local $bStringMatch2 = $oStringCompare.ContentsEqual("",True)
If (($oCredentials.JsonTypeOf("secret_key") <> 1) Or ($bStringMatch2 = True)) Then
ConsoleWrite("Missing or invalid secret_key." & @CRLF)
Exit
EndIf
$oHttp = ObjCreate("Chilkat.Http")
$oHttp.AwsAccessKey = $oCredentials.StringOf("access_key")
$oHttp.AwsSecretKey = $oCredentials.StringOf("secret_key")
If ($oCredentials.HasMember("session_token") = True) Then
$oStringCompare.SetString($oCredentials.StringOf("session_token"))
Local $bStringMatch3 = $oStringCompare.ContentsEqual("",True)
If (($oCredentials.JsonTypeOf("session_token") <> 1) Or ($bStringMatch3 = True)) Then
ConsoleWrite("session_token must be a nonempty string when supplied." & @CRLF)
Exit
EndIf
$oHttp.AwsSessionToken = $oCredentials.StringOf("session_token")
EndIf
; Use the provider's documented signing region and TLS endpoint.
; This reserved example endpoint must be replaced before running.
$oHttp.AwsRegion = "us-east-1"
$oHttp.AwsEndpoint = "objects.example.com"
$oHttp.RequireSslCertVerify = True
$oHttp.FollowRedirects = False
Local $sXmlStr = $oHttp.S3_ListBuckets()
If ($oHttp.LastMethodSuccess <> True) Then
ConsoleWrite("Request failed (transport or S3 error). HTTP status: " & $oHttp.LastStatus & @CRLF)
; Inspect LastErrorText privately. Do not log credentials or signed URLs.
Exit
EndIf
If ($oHttp.LastStatus <> 200) Then
ConsoleWrite("Unexpected HTTP status: " & $oHttp.LastStatus & @CRLF)
Exit
EndIf
$oXml = ObjCreate("Chilkat.Xml")
$bSuccess = $oXml.LoadXml($sXmlStr)
If ($bSuccess <> True) Then
ConsoleWrite("Invalid XML response." & @CRLF)
Exit
EndIf
$oStringCompare.SetString($oXml.Tag)
Local $bStringMatch4 = $oStringCompare.ContentsEqual("ListAllMyBucketsResult",True)
If ($bStringMatch4 <> True) Then
ConsoleWrite("Unexpected XML response root." & @CRLF)
Exit
EndIf
ConsoleWrite($oXml.GetXml() & @CRLF)
ConsoleWrite("Provider bucket response received; apply its documented pagination rules." & @CRLF)