Sample code for 30+ languages & platforms
PowerBuilder Requires Chilkat v11.6.0+

S3 Http: List Incomplete Multipart Uploads

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.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 explicit signed Http requests to preserve query parameters, conditional headers, and full responses. The included SigV4 block signs the exact path, sorted encoded query and headers used by this example; it is not a general-purpose HTTP signing library. Keep the clock accurate and do not change signed data after signing. Code requires Chilkat 11.6.0 or later; locally tested with 11.8.0.

Lists active multipart uploads with max-uploads=1000 and both pagination markers. Decodes encoded key markers once, while upload IDs remain opaque. Requires s3:ListBucketMultipartUploads. Useful after an uncertain initiation response or to find stale uploads. Listing does not abort anything; inspect the key, upload ID and application state before cleanup.

AWS reference

Chilkat PowerBuilder Downloads

PowerBuilder
integer li_rc
long li_Success
oleobject loo_StringCompare
oleobject loo_Credentials
long li_StringMatch1
long li_StringMatch2
oleobject loo_Http
long li_StringMatch3
string ls_Region
oleobject loo_Endpoint
string ls_BucketName
oleobject loo_Response
oleobject loo_Signer
oleobject loo_Now
oleobject loo_Timestamp
oleobject loo_Canonical
oleobject loo_CanonicalHeaders
oleobject loo_SignedHeaders
oleobject loo_Scope
oleobject loo_StringToSign
oleobject loo_SigningKey
oleobject loo_Authorization
oleobject loo_Url
oleobject loo_Query
oleobject loo_Number
oleobject loo_Host
oleobject loo_Uri
oleobject loo_Xml
string ls_AmzDate
string ls_DateStamp
string ls_PayloadHash
string ls_CanonicalHash
string ls_DerivedKey
string ls_Signature
long li_ReplaceCount
oleobject loo_Seen
long li_More
long li_Page
string ls_Marker
string ls_Truncated
string ls_Item
string ls_KeyMarker
string ls_UploadMarker
oleobject loo_Cursor
long li_StringMatch4
long li_StringMatch5
long li_StringMatch6
long li_StringMatch7
long i
long li_StringMatch8
long li_StringMatch9
long li_StringMatch10
long li_StringMatch11
long li_StringMatch12
long li_StringMatch13
long li_StringMatch14

li_Success = 0

loo_StringCompare = create oleobject
li_rc = loo_StringCompare.ConnectToNewObject("Chilkat.StringBuilder")
if li_rc < 0 then
    destroy loo_StringCompare
    MessageBox("Error","Connecting to COM object failed")
    return
end if
//  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.
loo_Credentials = create oleobject
li_rc = loo_Credentials.ConnectToNewObject("Chilkat.JsonObject")

loo_Credentials.Strict = 1
li_Success = loo_Credentials.LoadFile("qa_data/aws/s3.json")
if li_Success <> 1 then
    Write-Debug "Could not load private S3 credentials."
    destroy loo_StringCompare
    destroy loo_Credentials
    return
end if

loo_StringCompare.SetString(loo_Credentials.StringOf("access_key"))
li_StringMatch1 = loo_StringCompare.ContentsEqual("",1)
if (loo_Credentials.JsonTypeOf("access_key") <> 1) OR (li_StringMatch1 = 1) then
    Write-Debug "Missing or invalid access_key."
    destroy loo_StringCompare
    destroy loo_Credentials
    return
end if

loo_StringCompare.SetString(loo_Credentials.StringOf("secret_key"))
li_StringMatch2 = loo_StringCompare.ContentsEqual("",1)
if (loo_Credentials.JsonTypeOf("secret_key") <> 1) OR (li_StringMatch2 = 1) then
    Write-Debug "Missing or invalid secret_key."
    destroy loo_StringCompare
    destroy loo_Credentials
    return
end if

loo_Http = create oleobject
li_rc = loo_Http.ConnectToNewObject("Chilkat.Http")

loo_Http.AwsAccessKey = loo_Credentials.StringOf("access_key")
loo_Http.AwsSecretKey = loo_Credentials.StringOf("secret_key")
if loo_Credentials.HasMember("session_token") = 1 then
    loo_StringCompare.SetString(loo_Credentials.StringOf("session_token"))
    li_StringMatch3 = loo_StringCompare.ContentsEqual("",1)
    if (loo_Credentials.JsonTypeOf("session_token") <> 1) OR (li_StringMatch3 = 1) then
        Write-Debug "session_token must be a nonempty string when supplied."
        destroy loo_StringCompare
        destroy loo_Credentials
        destroy loo_Http
        return
    end if

    loo_Http.AwsSessionToken = loo_Credentials.StringOf("session_token")
end if

//  Current Chilkat uses SigV4 by default. Do not select deprecated SigV2.
//  Set the actual bucket region, not the caller's location.
ls_Region = "us-west-2"
loo_Http.AwsRegion = ls_Region
loo_Endpoint = create oleobject
li_rc = loo_Endpoint.ConnectToNewObject("Chilkat.StringBuilder")

loo_Endpoint.Append("s3.")
loo_Endpoint.Append(ls_Region)
loo_Endpoint.Append(".amazonaws.com")
loo_Http.AwsEndpoint = loo_Endpoint.GetAsString()
loo_Http.RequireSslCertVerify = 1
loo_Http.FollowRedirects = 0
//  A region redirect is not success. Correct the endpoint and signing region.
ls_BucketName = "your-bucket-name"
loo_Response = create oleobject
li_rc = loo_Response.ConnectToNewObject("Chilkat.HttpResponse")

loo_Signer = create oleobject
li_rc = loo_Signer.ConnectToNewObject("Chilkat.Crypt2")

loo_Signer.Charset = "utf-8"
loo_Signer.HashAlgorithm = "sha256"
loo_Signer.EncodingMode = "hexlower"
loo_Signer.MacAlgorithm = "hmac"
loo_Now = create oleobject
li_rc = loo_Now.ConnectToNewObject("Chilkat.CkDateTime")

loo_Timestamp = create oleobject
li_rc = loo_Timestamp.ConnectToNewObject("Chilkat.StringBuilder")

loo_Canonical = create oleobject
li_rc = loo_Canonical.ConnectToNewObject("Chilkat.StringBuilder")

loo_CanonicalHeaders = create oleobject
li_rc = loo_CanonicalHeaders.ConnectToNewObject("Chilkat.StringBuilder")

loo_SignedHeaders = create oleobject
li_rc = loo_SignedHeaders.ConnectToNewObject("Chilkat.StringBuilder")

loo_Scope = create oleobject
li_rc = loo_Scope.ConnectToNewObject("Chilkat.StringBuilder")

loo_StringToSign = create oleobject
li_rc = loo_StringToSign.ConnectToNewObject("Chilkat.StringBuilder")

loo_SigningKey = create oleobject
li_rc = loo_SigningKey.ConnectToNewObject("Chilkat.StringBuilder")

loo_Authorization = create oleobject
li_rc = loo_Authorization.ConnectToNewObject("Chilkat.StringBuilder")

loo_Url = create oleobject
li_rc = loo_Url.ConnectToNewObject("Chilkat.StringBuilder")

loo_Query = create oleobject
li_rc = loo_Query.ConnectToNewObject("Chilkat.StringBuilder")

loo_Number = create oleobject
li_rc = loo_Number.ConnectToNewObject("Chilkat.StringBuilder")

loo_Host = create oleobject
li_rc = loo_Host.ConnectToNewObject("Chilkat.StringBuilder")

loo_Uri = create oleobject
li_rc = loo_Uri.ConnectToNewObject("Chilkat.StringBuilder")

loo_Xml = create oleobject
li_rc = loo_Xml.ConnectToNewObject("Chilkat.Xml")

loo_Host.Append(ls_BucketName)
loo_Host.Append(".")
loo_Host.Append(loo_Endpoint.GetAsString())
loo_Uri.Append("/")
loo_Seen = create oleobject
li_rc = loo_Seen.ConnectToNewObject("Chilkat.Hashtable")

li_More = 1
li_Page = 0
ls_Marker = ""

ls_KeyMarker = ""
ls_UploadMarker = ""
loo_Cursor = create oleobject
li_rc = loo_Cursor.ConnectToNewObject("Chilkat.JsonObject")

do while (li_More = 1)
    if li_Page = 10000 then
        Write-Debug "Page bound reached; results are incomplete."
        destroy loo_StringCompare
        destroy loo_Credentials
        destroy loo_Http
        destroy loo_Endpoint
        destroy loo_Response
        destroy loo_Signer
        destroy loo_Now
        destroy loo_Timestamp
        destroy loo_Canonical
        destroy loo_CanonicalHeaders
        destroy loo_SignedHeaders
        destroy loo_Scope
        destroy loo_StringToSign
        destroy loo_SigningKey
        destroy loo_Authorization
        destroy loo_Url
        destroy loo_Query
        destroy loo_Number
        destroy loo_Host
        destroy loo_Uri
        destroy loo_Xml
        destroy loo_Seen
        destroy loo_Cursor
        return
    end if

    li_Page = li_Page + 1
    loo_Query.Clear()
    if loo_Query.Length > 0 then
        loo_Query.Append("&")
    end if

    loo_Query.Append("encoding-type=")
    loo_Query.Append(loo_Http.UrlEncode("url"))
    loo_StringCompare.SetString(ls_KeyMarker)
    li_StringMatch4 = loo_StringCompare.ContentsEqual("",1)
    if li_StringMatch4 <> 1 then
        if loo_Query.Length > 0 then
            loo_Query.Append("&")
        end if

        loo_Query.Append("key-marker=")
        loo_Query.Append(loo_Http.UrlEncode(ls_KeyMarker))
    end if

    if loo_Query.Length > 0 then
        loo_Query.Append("&")
    end if

    loo_Query.Append("max-uploads=")
    loo_Query.Append(loo_Http.UrlEncode("1000"))
    loo_StringCompare.SetString(ls_UploadMarker)
    li_StringMatch5 = loo_StringCompare.ContentsEqual("",1)
    if li_StringMatch5 <> 1 then
        if loo_Query.Length > 0 then
            loo_Query.Append("&")
        end if

        loo_Query.Append("upload-id-marker=")
        loo_Query.Append(loo_Http.UrlEncode(ls_UploadMarker))
    end if

    if loo_Query.Length > 0 then
        loo_Query.Append("&")
    end if

    loo_Query.Append("uploads=")
    loo_Query.Append(loo_Http.UrlEncode(""))
    loo_Http.ClearHeaders()
    li_Success = loo_Now.SetFromCurrentSystemTime()
    if li_Success <> 1 then
        Write-Debug "Could not read system time."
        destroy loo_StringCompare
        destroy loo_Credentials
        destroy loo_Http
        destroy loo_Endpoint
        destroy loo_Response
        destroy loo_Signer
        destroy loo_Now
        destroy loo_Timestamp
        destroy loo_Canonical
        destroy loo_CanonicalHeaders
        destroy loo_SignedHeaders
        destroy loo_Scope
        destroy loo_StringToSign
        destroy loo_SigningKey
        destroy loo_Authorization
        destroy loo_Url
        destroy loo_Query
        destroy loo_Number
        destroy loo_Host
        destroy loo_Uri
        destroy loo_Xml
        destroy loo_Seen
        destroy loo_Cursor
        return
    end if

    loo_Timestamp.SetString(loo_Now.GetAsTimestamp(0))
    li_ReplaceCount = loo_Timestamp.Replace("-","")
    li_ReplaceCount = loo_Timestamp.Replace(":","")
    ls_AmzDate = loo_Timestamp.GetAsString()
    ls_DateStamp = loo_Timestamp.GetRange(0,8,0)
    ls_PayloadHash = loo_Signer.HashStringENC("")
    if loo_Signer.LastMethodSuccess <> 1 then
        Write-Debug "Could not hash payload."
        destroy loo_StringCompare
        destroy loo_Credentials
        destroy loo_Http
        destroy loo_Endpoint
        destroy loo_Response
        destroy loo_Signer
        destroy loo_Now
        destroy loo_Timestamp
        destroy loo_Canonical
        destroy loo_CanonicalHeaders
        destroy loo_SignedHeaders
        destroy loo_Scope
        destroy loo_StringToSign
        destroy loo_SigningKey
        destroy loo_Authorization
        destroy loo_Url
        destroy loo_Query
        destroy loo_Number
        destroy loo_Host
        destroy loo_Uri
        destroy loo_Xml
        destroy loo_Seen
        destroy loo_Cursor
        return
    end if

    loo_CanonicalHeaders.Clear()
    loo_SignedHeaders.Clear()
    if loo_SignedHeaders.Length > 0 then
        loo_SignedHeaders.Append(";")
    end if

    loo_SignedHeaders.Append("host")
    loo_CanonicalHeaders.Append("host:")
    loo_CanonicalHeaders.Append(loo_Host.GetAsString())
    loo_CanonicalHeaders.Append("~n")
    loo_Http.SetRequestHeader("host",loo_Host.GetAsString())
    if loo_SignedHeaders.Length > 0 then
        loo_SignedHeaders.Append(";")
    end if

    loo_SignedHeaders.Append("x-amz-content-sha256")
    loo_CanonicalHeaders.Append("x-amz-content-sha256:")
    loo_CanonicalHeaders.Append(ls_PayloadHash)
    loo_CanonicalHeaders.Append("~n")
    loo_Http.SetRequestHeader("x-amz-content-sha256",ls_PayloadHash)
    if loo_SignedHeaders.Length > 0 then
        loo_SignedHeaders.Append(";")
    end if

    loo_SignedHeaders.Append("x-amz-date")
    loo_CanonicalHeaders.Append("x-amz-date:")
    loo_CanonicalHeaders.Append(ls_AmzDate)
    loo_CanonicalHeaders.Append("~n")
    loo_Http.SetRequestHeader("x-amz-date",ls_AmzDate)
    if loo_Credentials.HasMember("session_token") = 1 then
        if loo_SignedHeaders.Length > 0 then
            loo_SignedHeaders.Append(";")
        end if

        loo_SignedHeaders.Append("x-amz-security-token")
        loo_CanonicalHeaders.Append("x-amz-security-token:")
        loo_CanonicalHeaders.Append(loo_Credentials.StringOf("session_token"))
        loo_CanonicalHeaders.Append("~n")
        loo_Http.SetRequestHeader("x-amz-security-token",loo_Credentials.StringOf("session_token"))
    end if

    loo_Canonical.Clear()
    loo_Canonical.Append("GET~n")
    loo_Canonical.Append(loo_Uri.GetAsString())
    loo_Canonical.Append("~n")
    loo_Canonical.Append(loo_Query.GetAsString())
    loo_Canonical.Append("~n")
    loo_Canonical.Append(loo_CanonicalHeaders.GetAsString())
    loo_Canonical.Append("~n")
    loo_Canonical.Append(loo_SignedHeaders.GetAsString())
    loo_Canonical.Append("~n")
    loo_Canonical.Append(ls_PayloadHash)
    ls_CanonicalHash = loo_Signer.HashStringENC(loo_Canonical.GetAsString())
    if loo_Signer.LastMethodSuccess <> 1 then
        Write-Debug "Could not hash canonical request."
        destroy loo_StringCompare
        destroy loo_Credentials
        destroy loo_Http
        destroy loo_Endpoint
        destroy loo_Response
        destroy loo_Signer
        destroy loo_Now
        destroy loo_Timestamp
        destroy loo_Canonical
        destroy loo_CanonicalHeaders
        destroy loo_SignedHeaders
        destroy loo_Scope
        destroy loo_StringToSign
        destroy loo_SigningKey
        destroy loo_Authorization
        destroy loo_Url
        destroy loo_Query
        destroy loo_Number
        destroy loo_Host
        destroy loo_Uri
        destroy loo_Xml
        destroy loo_Seen
        destroy loo_Cursor
        return
    end if

    loo_Scope.Clear()
    loo_Scope.Append(ls_DateStamp)
    loo_Scope.Append("/")
    loo_Scope.Append(ls_Region)
    loo_Scope.Append("/s3/aws4_request")
    loo_StringToSign.Clear()
    loo_StringToSign.Append("AWS4-HMAC-SHA256~n")
    loo_StringToSign.Append(ls_AmzDate)
    loo_StringToSign.Append("~n")
    loo_StringToSign.Append(loo_Scope.GetAsString())
    loo_StringToSign.Append("~n")
    loo_StringToSign.Append(ls_CanonicalHash)
    loo_SigningKey.SetString("AWS4")
    loo_SigningKey.Append(loo_Credentials.StringOf("secret_key"))
    li_Success = loo_Signer.SetMacKeyString(loo_SigningKey.GetAsString())
    if li_Success <> 1 then
        Write-Debug "Could not set signing key."
        destroy loo_StringCompare
        destroy loo_Credentials
        destroy loo_Http
        destroy loo_Endpoint
        destroy loo_Response
        destroy loo_Signer
        destroy loo_Now
        destroy loo_Timestamp
        destroy loo_Canonical
        destroy loo_CanonicalHeaders
        destroy loo_SignedHeaders
        destroy loo_Scope
        destroy loo_StringToSign
        destroy loo_SigningKey
        destroy loo_Authorization
        destroy loo_Url
        destroy loo_Query
        destroy loo_Number
        destroy loo_Host
        destroy loo_Uri
        destroy loo_Xml
        destroy loo_Seen
        destroy loo_Cursor
        return
    end if

    ls_DerivedKey = loo_Signer.MacStringENC(ls_DateStamp)
    if loo_Signer.LastMethodSuccess <> 1 then
        Write-Debug "Could not derive signing key."
        destroy loo_StringCompare
        destroy loo_Credentials
        destroy loo_Http
        destroy loo_Endpoint
        destroy loo_Response
        destroy loo_Signer
        destroy loo_Now
        destroy loo_Timestamp
        destroy loo_Canonical
        destroy loo_CanonicalHeaders
        destroy loo_SignedHeaders
        destroy loo_Scope
        destroy loo_StringToSign
        destroy loo_SigningKey
        destroy loo_Authorization
        destroy loo_Url
        destroy loo_Query
        destroy loo_Number
        destroy loo_Host
        destroy loo_Uri
        destroy loo_Xml
        destroy loo_Seen
        destroy loo_Cursor
        return
    end if

    li_Success = loo_Signer.SetMacKeyEncoded(ls_DerivedKey,"hex")
    if li_Success <> 1 then
        Write-Debug "Could not set signing key."
        destroy loo_StringCompare
        destroy loo_Credentials
        destroy loo_Http
        destroy loo_Endpoint
        destroy loo_Response
        destroy loo_Signer
        destroy loo_Now
        destroy loo_Timestamp
        destroy loo_Canonical
        destroy loo_CanonicalHeaders
        destroy loo_SignedHeaders
        destroy loo_Scope
        destroy loo_StringToSign
        destroy loo_SigningKey
        destroy loo_Authorization
        destroy loo_Url
        destroy loo_Query
        destroy loo_Number
        destroy loo_Host
        destroy loo_Uri
        destroy loo_Xml
        destroy loo_Seen
        destroy loo_Cursor
        return
    end if

    ls_DerivedKey = loo_Signer.MacStringENC(ls_Region)
    if loo_Signer.LastMethodSuccess <> 1 then
        Write-Debug "Could not derive signing key."
        destroy loo_StringCompare
        destroy loo_Credentials
        destroy loo_Http
        destroy loo_Endpoint
        destroy loo_Response
        destroy loo_Signer
        destroy loo_Now
        destroy loo_Timestamp
        destroy loo_Canonical
        destroy loo_CanonicalHeaders
        destroy loo_SignedHeaders
        destroy loo_Scope
        destroy loo_StringToSign
        destroy loo_SigningKey
        destroy loo_Authorization
        destroy loo_Url
        destroy loo_Query
        destroy loo_Number
        destroy loo_Host
        destroy loo_Uri
        destroy loo_Xml
        destroy loo_Seen
        destroy loo_Cursor
        return
    end if

    li_Success = loo_Signer.SetMacKeyEncoded(ls_DerivedKey,"hex")
    if li_Success <> 1 then
        Write-Debug "Could not set signing key."
        destroy loo_StringCompare
        destroy loo_Credentials
        destroy loo_Http
        destroy loo_Endpoint
        destroy loo_Response
        destroy loo_Signer
        destroy loo_Now
        destroy loo_Timestamp
        destroy loo_Canonical
        destroy loo_CanonicalHeaders
        destroy loo_SignedHeaders
        destroy loo_Scope
        destroy loo_StringToSign
        destroy loo_SigningKey
        destroy loo_Authorization
        destroy loo_Url
        destroy loo_Query
        destroy loo_Number
        destroy loo_Host
        destroy loo_Uri
        destroy loo_Xml
        destroy loo_Seen
        destroy loo_Cursor
        return
    end if

    ls_DerivedKey = loo_Signer.MacStringENC("s3")
    if loo_Signer.LastMethodSuccess <> 1 then
        Write-Debug "Could not derive signing key."
        destroy loo_StringCompare
        destroy loo_Credentials
        destroy loo_Http
        destroy loo_Endpoint
        destroy loo_Response
        destroy loo_Signer
        destroy loo_Now
        destroy loo_Timestamp
        destroy loo_Canonical
        destroy loo_CanonicalHeaders
        destroy loo_SignedHeaders
        destroy loo_Scope
        destroy loo_StringToSign
        destroy loo_SigningKey
        destroy loo_Authorization
        destroy loo_Url
        destroy loo_Query
        destroy loo_Number
        destroy loo_Host
        destroy loo_Uri
        destroy loo_Xml
        destroy loo_Seen
        destroy loo_Cursor
        return
    end if

    li_Success = loo_Signer.SetMacKeyEncoded(ls_DerivedKey,"hex")
    if li_Success <> 1 then
        Write-Debug "Could not set signing key."
        destroy loo_StringCompare
        destroy loo_Credentials
        destroy loo_Http
        destroy loo_Endpoint
        destroy loo_Response
        destroy loo_Signer
        destroy loo_Now
        destroy loo_Timestamp
        destroy loo_Canonical
        destroy loo_CanonicalHeaders
        destroy loo_SignedHeaders
        destroy loo_Scope
        destroy loo_StringToSign
        destroy loo_SigningKey
        destroy loo_Authorization
        destroy loo_Url
        destroy loo_Query
        destroy loo_Number
        destroy loo_Host
        destroy loo_Uri
        destroy loo_Xml
        destroy loo_Seen
        destroy loo_Cursor
        return
    end if

    ls_DerivedKey = loo_Signer.MacStringENC("aws4_request")
    if loo_Signer.LastMethodSuccess <> 1 then
        Write-Debug "Could not derive signing key."
        destroy loo_StringCompare
        destroy loo_Credentials
        destroy loo_Http
        destroy loo_Endpoint
        destroy loo_Response
        destroy loo_Signer
        destroy loo_Now
        destroy loo_Timestamp
        destroy loo_Canonical
        destroy loo_CanonicalHeaders
        destroy loo_SignedHeaders
        destroy loo_Scope
        destroy loo_StringToSign
        destroy loo_SigningKey
        destroy loo_Authorization
        destroy loo_Url
        destroy loo_Query
        destroy loo_Number
        destroy loo_Host
        destroy loo_Uri
        destroy loo_Xml
        destroy loo_Seen
        destroy loo_Cursor
        return
    end if

    li_Success = loo_Signer.SetMacKeyEncoded(ls_DerivedKey,"hex")
    if li_Success <> 1 then
        Write-Debug "Could not set signing key."
        destroy loo_StringCompare
        destroy loo_Credentials
        destroy loo_Http
        destroy loo_Endpoint
        destroy loo_Response
        destroy loo_Signer
        destroy loo_Now
        destroy loo_Timestamp
        destroy loo_Canonical
        destroy loo_CanonicalHeaders
        destroy loo_SignedHeaders
        destroy loo_Scope
        destroy loo_StringToSign
        destroy loo_SigningKey
        destroy loo_Authorization
        destroy loo_Url
        destroy loo_Query
        destroy loo_Number
        destroy loo_Host
        destroy loo_Uri
        destroy loo_Xml
        destroy loo_Seen
        destroy loo_Cursor
        return
    end if

    ls_Signature = loo_Signer.MacStringENC(loo_StringToSign.GetAsString())
    if loo_Signer.LastMethodSuccess <> 1 then
        Write-Debug "Could not sign request."
        destroy loo_StringCompare
        destroy loo_Credentials
        destroy loo_Http
        destroy loo_Endpoint
        destroy loo_Response
        destroy loo_Signer
        destroy loo_Now
        destroy loo_Timestamp
        destroy loo_Canonical
        destroy loo_CanonicalHeaders
        destroy loo_SignedHeaders
        destroy loo_Scope
        destroy loo_StringToSign
        destroy loo_SigningKey
        destroy loo_Authorization
        destroy loo_Url
        destroy loo_Query
        destroy loo_Number
        destroy loo_Host
        destroy loo_Uri
        destroy loo_Xml
        destroy loo_Seen
        destroy loo_Cursor
        return
    end if

    loo_Authorization.Clear()
    loo_Authorization.Append("AWS4-HMAC-SHA256 Credential=")
    loo_Authorization.Append(loo_Credentials.StringOf("access_key"))
    loo_Authorization.Append("/")
    loo_Authorization.Append(loo_Scope.GetAsString())
    loo_Authorization.Append(", SignedHeaders=")
    loo_Authorization.Append(loo_SignedHeaders.GetAsString())
    loo_Authorization.Append(", Signature=")
    loo_Authorization.Append(ls_Signature)
    loo_Http.SetRequestHeader("Authorization",loo_Authorization.GetAsString())
    loo_Url.SetString("https://")
    loo_Url.Append(loo_Host.GetAsString())
    loo_Url.Append(loo_Uri.GetAsString())
    if loo_Query.Length > 0 then
        loo_Url.Append("?")
        loo_Url.Append(loo_Query.GetAsString())
    end if

    li_Success = loo_Http.HttpNoBody("GET",loo_Url.GetAsString(),loo_Response)
    if (li_Success <> 1) OR (loo_Response.StatusCode <> 200) then
        Write-Debug "Request failed or returned unexpected HTTP status: " + string(loo_Response.StatusCode)
        //  Preserve progress. Inspect full diagnostics privately; do not log secrets.
        destroy loo_StringCompare
        destroy loo_Credentials
        destroy loo_Http
        destroy loo_Endpoint
        destroy loo_Response
        destroy loo_Signer
        destroy loo_Now
        destroy loo_Timestamp
        destroy loo_Canonical
        destroy loo_CanonicalHeaders
        destroy loo_SignedHeaders
        destroy loo_Scope
        destroy loo_StringToSign
        destroy loo_SigningKey
        destroy loo_Authorization
        destroy loo_Url
        destroy loo_Query
        destroy loo_Number
        destroy loo_Host
        destroy loo_Uri
        destroy loo_Xml
        destroy loo_Seen
        destroy loo_Cursor
        return
    end if

    li_Success = loo_Xml.LoadXml(loo_Response.BodyStr)
    if li_Success <> 1 then
        Write-Debug "Invalid XML response."
        destroy loo_StringCompare
        destroy loo_Credentials
        destroy loo_Http
        destroy loo_Endpoint
        destroy loo_Response
        destroy loo_Signer
        destroy loo_Now
        destroy loo_Timestamp
        destroy loo_Canonical
        destroy loo_CanonicalHeaders
        destroy loo_SignedHeaders
        destroy loo_Scope
        destroy loo_StringToSign
        destroy loo_SigningKey
        destroy loo_Authorization
        destroy loo_Url
        destroy loo_Query
        destroy loo_Number
        destroy loo_Host
        destroy loo_Uri
        destroy loo_Xml
        destroy loo_Seen
        destroy loo_Cursor
        return
    end if

    loo_StringCompare.SetString(loo_Xml.Tag)
    li_StringMatch6 = loo_StringCompare.ContentsEqual("ListMultipartUploadsResult",1)
    if li_StringMatch6 <> 1 then
        Write-Debug "Unexpected XML result, possibly an embedded S3 error. Inspect privately."
        destroy loo_StringCompare
        destroy loo_Credentials
        destroy loo_Http
        destroy loo_Endpoint
        destroy loo_Response
        destroy loo_Signer
        destroy loo_Now
        destroy loo_Timestamp
        destroy loo_Canonical
        destroy loo_CanonicalHeaders
        destroy loo_SignedHeaders
        destroy loo_Scope
        destroy loo_StringToSign
        destroy loo_SigningKey
        destroy loo_Authorization
        destroy loo_Url
        destroy loo_Query
        destroy loo_Number
        destroy loo_Host
        destroy loo_Uri
        destroy loo_Xml
        destroy loo_Seen
        destroy loo_Cursor
        return
    end if

    loo_StringCompare.SetString(loo_Xml.GetChildContent("EncodingType"))
    li_StringMatch7 = loo_StringCompare.ContentsEqual("url",1)
    if li_StringMatch7 <> 1 then
        Write-Debug "Expected URL encoding."
        destroy loo_StringCompare
        destroy loo_Credentials
        destroy loo_Http
        destroy loo_Endpoint
        destroy loo_Response
        destroy loo_Signer
        destroy loo_Now
        destroy loo_Timestamp
        destroy loo_Canonical
        destroy loo_CanonicalHeaders
        destroy loo_SignedHeaders
        destroy loo_Scope
        destroy loo_StringToSign
        destroy loo_SigningKey
        destroy loo_Authorization
        destroy loo_Url
        destroy loo_Query
        destroy loo_Number
        destroy loo_Host
        destroy loo_Uri
        destroy loo_Xml
        destroy loo_Seen
        destroy loo_Cursor
        return
    end if

    i = 0
    do while (i < loo_Xml.NumChildrenHavingTag("Upload"))
        loo_Xml.I = i
        ls_Item = loo_Xml.GetChildContent("Upload[i]|Key")
        loo_StringCompare.SetString(ls_Item)
        li_StringMatch8 = loo_StringCompare.ContentsEqual("",1)
        if (loo_Xml.LastMethodSuccess <> 1) OR (li_StringMatch8 = 1) then
            Write-Debug "Missing required Upload[i]|Key."
            destroy loo_StringCompare
            destroy loo_Credentials
            destroy loo_Http
            destroy loo_Endpoint
            destroy loo_Response
            destroy loo_Signer
            destroy loo_Now
            destroy loo_Timestamp
            destroy loo_Canonical
            destroy loo_CanonicalHeaders
            destroy loo_SignedHeaders
            destroy loo_Scope
            destroy loo_StringToSign
            destroy loo_SigningKey
            destroy loo_Authorization
            destroy loo_Url
            destroy loo_Query
            destroy loo_Number
            destroy loo_Host
            destroy loo_Uri
            destroy loo_Xml
            destroy loo_Seen
            destroy loo_Cursor
            return
        end if

        Write-Debug "Key: " + loo_Http.UrlDecode(ls_Item)
        ls_Item = loo_Xml.GetChildContent("Upload[i]|UploadId")
        loo_StringCompare.SetString(ls_Item)
        li_StringMatch9 = loo_StringCompare.ContentsEqual("",1)
        if (loo_Xml.LastMethodSuccess <> 1) OR (li_StringMatch9 = 1) then
            Write-Debug "Missing required Upload[i]|UploadId."
            destroy loo_StringCompare
            destroy loo_Credentials
            destroy loo_Http
            destroy loo_Endpoint
            destroy loo_Response
            destroy loo_Signer
            destroy loo_Now
            destroy loo_Timestamp
            destroy loo_Canonical
            destroy loo_CanonicalHeaders
            destroy loo_SignedHeaders
            destroy loo_Scope
            destroy loo_StringToSign
            destroy loo_SigningKey
            destroy loo_Authorization
            destroy loo_Url
            destroy loo_Query
            destroy loo_Number
            destroy loo_Host
            destroy loo_Uri
            destroy loo_Xml
            destroy loo_Seen
            destroy loo_Cursor
            return
        end if

        Write-Debug "Upload ID: " + ls_Item
        i = i + 1
    loop
    ls_Truncated = loo_Xml.GetChildContent("IsTruncated")
    loo_StringCompare.SetString(ls_Truncated)
    li_StringMatch10 = loo_StringCompare.ContentsEqual("",1)
    if (loo_Xml.LastMethodSuccess <> 1) OR (li_StringMatch10 = 1) then
        Write-Debug "Missing required IsTruncated."
        destroy loo_StringCompare
        destroy loo_Credentials
        destroy loo_Http
        destroy loo_Endpoint
        destroy loo_Response
        destroy loo_Signer
        destroy loo_Now
        destroy loo_Timestamp
        destroy loo_Canonical
        destroy loo_CanonicalHeaders
        destroy loo_SignedHeaders
        destroy loo_Scope
        destroy loo_StringToSign
        destroy loo_SigningKey
        destroy loo_Authorization
        destroy loo_Url
        destroy loo_Query
        destroy loo_Number
        destroy loo_Host
        destroy loo_Uri
        destroy loo_Xml
        destroy loo_Seen
        destroy loo_Cursor
        return
    end if

    loo_StringCompare.SetString(ls_Truncated)
    li_StringMatch11 = loo_StringCompare.ContentsEqual("true",1)
    loo_StringCompare.SetString(ls_Truncated)
    li_StringMatch12 = loo_StringCompare.ContentsEqual("false",1)
    if (li_StringMatch11 <> 1) AND (li_StringMatch12 <> 1) then
        Write-Debug "Invalid IsTruncated."
        destroy loo_StringCompare
        destroy loo_Credentials
        destroy loo_Http
        destroy loo_Endpoint
        destroy loo_Response
        destroy loo_Signer
        destroy loo_Now
        destroy loo_Timestamp
        destroy loo_Canonical
        destroy loo_CanonicalHeaders
        destroy loo_SignedHeaders
        destroy loo_Scope
        destroy loo_StringToSign
        destroy loo_SigningKey
        destroy loo_Authorization
        destroy loo_Url
        destroy loo_Query
        destroy loo_Number
        destroy loo_Host
        destroy loo_Uri
        destroy loo_Xml
        destroy loo_Seen
        destroy loo_Cursor
        return
    end if

    li_More = 0
    loo_StringCompare.SetString(ls_Truncated)
    li_StringMatch13 = loo_StringCompare.ContentsEqual("true",1)
    if li_StringMatch13 = 1 then
        ls_KeyMarker = loo_Xml.GetChildContent("NextKeyMarker")
        loo_StringCompare.SetString(ls_KeyMarker)
        li_StringMatch14 = loo_StringCompare.ContentsEqual("",1)
        if (loo_Xml.LastMethodSuccess <> 1) OR (li_StringMatch14 = 1) then
            Write-Debug "Missing required NextKeyMarker."
            destroy loo_StringCompare
            destroy loo_Credentials
            destroy loo_Http
            destroy loo_Endpoint
            destroy loo_Response
            destroy loo_Signer
            destroy loo_Now
            destroy loo_Timestamp
            destroy loo_Canonical
            destroy loo_CanonicalHeaders
            destroy loo_SignedHeaders
            destroy loo_Scope
            destroy loo_StringToSign
            destroy loo_SigningKey
            destroy loo_Authorization
            destroy loo_Url
            destroy loo_Query
            destroy loo_Number
            destroy loo_Host
            destroy loo_Uri
            destroy loo_Xml
            destroy loo_Seen
            destroy loo_Cursor
            return
        end if

        ls_KeyMarker = loo_Http.UrlDecode(ls_KeyMarker)
        ls_UploadMarker = ""
        if loo_Xml.HasChildWithTag("NextUploadIdMarker") = 1 then
            ls_UploadMarker = loo_Xml.GetChildContent("NextUploadIdMarker")
        end if

        li_Success = loo_Cursor.UpdateString("key",ls_KeyMarker)
        if li_Success <> 1 then
            Write-Debug "Could not save key."
            destroy loo_StringCompare
            destroy loo_Credentials
            destroy loo_Http
            destroy loo_Endpoint
            destroy loo_Response
            destroy loo_Signer
            destroy loo_Now
            destroy loo_Timestamp
            destroy loo_Canonical
            destroy loo_CanonicalHeaders
            destroy loo_SignedHeaders
            destroy loo_Scope
            destroy loo_StringToSign
            destroy loo_SigningKey
            destroy loo_Authorization
            destroy loo_Url
            destroy loo_Query
            destroy loo_Number
            destroy loo_Host
            destroy loo_Uri
            destroy loo_Xml
            destroy loo_Seen
            destroy loo_Cursor
            return
        end if

        li_Success = loo_Cursor.UpdateString("upload",ls_UploadMarker)
        if li_Success <> 1 then
            Write-Debug "Could not save upload."
            destroy loo_StringCompare
            destroy loo_Credentials
            destroy loo_Http
            destroy loo_Endpoint
            destroy loo_Response
            destroy loo_Signer
            destroy loo_Now
            destroy loo_Timestamp
            destroy loo_Canonical
            destroy loo_CanonicalHeaders
            destroy loo_SignedHeaders
            destroy loo_Scope
            destroy loo_StringToSign
            destroy loo_SigningKey
            destroy loo_Authorization
            destroy loo_Url
            destroy loo_Query
            destroy loo_Number
            destroy loo_Host
            destroy loo_Uri
            destroy loo_Xml
            destroy loo_Seen
            destroy loo_Cursor
            return
        end if

        ls_Marker = loo_Cursor.Emit()
        if loo_Seen.Contains(ls_Marker) = 1 then
            Write-Debug "Repeated multipart cursor."
            destroy loo_StringCompare
            destroy loo_Credentials
            destroy loo_Http
            destroy loo_Endpoint
            destroy loo_Response
            destroy loo_Signer
            destroy loo_Now
            destroy loo_Timestamp
            destroy loo_Canonical
            destroy loo_CanonicalHeaders
            destroy loo_SignedHeaders
            destroy loo_Scope
            destroy loo_StringToSign
            destroy loo_SigningKey
            destroy loo_Authorization
            destroy loo_Url
            destroy loo_Query
            destroy loo_Number
            destroy loo_Host
            destroy loo_Uri
            destroy loo_Xml
            destroy loo_Seen
            destroy loo_Cursor
            return
        end if

        li_Success = loo_Seen.AddStr(ls_Marker,"seen")
        if li_Success <> 1 then
            Write-Debug "Could not track cursor."
            destroy loo_StringCompare
            destroy loo_Credentials
            destroy loo_Http
            destroy loo_Endpoint
            destroy loo_Response
            destroy loo_Signer
            destroy loo_Now
            destroy loo_Timestamp
            destroy loo_Canonical
            destroy loo_CanonicalHeaders
            destroy loo_SignedHeaders
            destroy loo_Scope
            destroy loo_StringToSign
            destroy loo_SigningKey
            destroy loo_Authorization
            destroy loo_Url
            destroy loo_Query
            destroy loo_Number
            destroy loo_Host
            destroy loo_Uri
            destroy loo_Xml
            destroy loo_Seen
            destroy loo_Cursor
            return
        end if

        li_More = 1
    end if

loop
Write-Debug "Multipart upload listing complete."


destroy loo_StringCompare
destroy loo_Credentials
destroy loo_Http
destroy loo_Endpoint
destroy loo_Response
destroy loo_Signer
destroy loo_Now
destroy loo_Timestamp
destroy loo_Canonical
destroy loo_CanonicalHeaders
destroy loo_SignedHeaders
destroy loo_Scope
destroy loo_StringToSign
destroy loo_SigningKey
destroy loo_Authorization
destroy loo_Url
destroy loo_Query
destroy loo_Number
destroy loo_Host
destroy loo_Uri
destroy loo_Xml
destroy loo_Seen
destroy loo_Cursor