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

Amazon Glacier: List Multipart Uploads with Pagination

See more Amazon Glacier Examples

For existing Amazon Glacier vault customers. The standalone vault service is closed to new customers. These examples use its REST API version 2012-06-01, not the S3 bucket APIs used by S3 Glacier storage classes. See AWS service guidance.

Lists in-progress uploads, following opaque Marker values even after an empty page. Uses the documented maximum limit of 50 and detects cycles. Completed uploads are absent. Descriptions need not be unique: inspect IDs, vault, time, and part size before selecting an upload to resume or abort. This listing is not an atomic snapshot. Part sizes remain decimal strings, including sizes above 2 GiB.

Uses AWS Signature Version 4 with service glacier. Set the region once; the example builds the commercial AWS endpoint. Other partitions require the appropriate endpoint suffix. /-/ selects the signing account; change the vault name and IDs to your own resources. Load private qa_data/aws/glacier.json with string fields access_key, secret_key, and session_token for temporary credentials. Prefer short-lived role credentials. This sample does not discover profiles or refresh credentials. TLS certificate verification is enabled explicitly.

Checks transport completion, the operation-specific HTTP status, and parsed data separately. Inspect full diagnostics privately. Renew expired credentials; use bounded backoff with jitter for retryable reads. Uploads and job initiation can succeed before a connection fails, so do not blindly resubmit them. Configure IAM permissions for only the required operations and vault resources.

AWS reference

Chilkat Classic ASP Downloads

Classic ASP
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<%
'  Assumes Chilkat is unlocked. See Global Unlock Sample.
success = 0
'  Private configuration, not a file in public web content or source control.
'  Load current IAM credentials authorized for the Glacier operation.
set credentials = Server.CreateObject("Chilkat.JsonObject")
credentials.Strict = 1
success = credentials.LoadFile("qa_data/aws/glacier.json")
If (success <> 1) Then
    Response.Write "<pre>" & Server.HTMLEncode( "Could not load private AWS credentials.") & "</pre>"
    Response.End
End If

If ((credentials.JsonTypeOf("access_key") <> 1) Or (credentials.StringOf("access_key") = "")) Then
    Response.Write "<pre>" & Server.HTMLEncode( "Missing or invalid access_key.") & "</pre>"
    Response.End
End If

If ((credentials.JsonTypeOf("secret_key") <> 1) Or (credentials.StringOf("secret_key") = "")) Then
    Response.Write "<pre>" & Server.HTMLEncode( "Missing or invalid secret_key.") & "</pre>"
    Response.End
End If

'  Set this once to the region containing the vault.
region = "us-west-2"
set endpoint = Server.CreateObject("Chilkat.StringBuilder")
success = endpoint.Append("glacier.")
success = endpoint.Append(region)
success = endpoint.Append(".amazonaws.com")
set aws = Server.CreateObject("Chilkat.AuthAws")
aws.AccessKey = credentials.StringOf("access_key")
aws.SecretKey = credentials.StringOf("secret_key")
aws.Region = region
aws.ServiceName = "glacier"
aws.SignatureVersion = 4
set rest = Server.CreateObject("Chilkat.Rest")
rest.ConnectTimeoutMs = 20000
rest.IdleTimeoutMs = 60000
success = rest.SetAuthAws(aws)
If (success <> 1) Then
    Response.Write "<pre>" & Server.HTMLEncode( "Could not configure AWS signing.") & "</pre>"
    Response.End
End If

'  Temporary IAM/STS credentials require their session token on every signed request.
'  Include the token in the signed query. Keep request URLs and diagnostics private.
'  Leave session_token absent or empty only for credentials that do not have one.
If (credentials.HasMember("session_token") = 1) Then
    If (credentials.JsonTypeOf("session_token") <> 1) Then
        Response.Write "<pre>" & Server.HTMLEncode( "session_token must be a string.") & "</pre>"
        Response.End
    End If

    If (credentials.StringOf("session_token") <> "") Then
        success = rest.AddQueryParam("X-Amz-Security-Token",credentials.StringOf("session_token"))
        If (success <> 1) Then
            Response.Write "<pre>" & Server.HTMLEncode( "Could not set the session-token parameter.") & "</pre>"
            Response.End
        End If

    End If

End If

'  Supply a Socket to explicitly enable TLS certificate verification.
set connection = Server.CreateObject("Chilkat.Socket")
connection.RequireSslCertVerify = 1
connection.MaxReadIdleMs = 60000
connection.MaxSendIdleMs = 60000
success = connection.Connect(endpoint.GetAsString(),443,1,20000)
If (success <> 1) Then
    Response.Write "<pre>" & Server.HTMLEncode( "TLS connection failed; inspect diagnostics privately.") & "</pre>"
    Response.End
End If

success = rest.UseConnection(connection,1)
If (success <> 1) Then
    Response.Write "<pre>" & Server.HTMLEncode( "Could not attach the TLS connection.") & "</pre>"
    Response.End
End If

success = rest.AddHeader("x-amz-glacier-version","2012-06-01")
If (success <> 1) Then
    Response.Write "<pre>" & Server.HTMLEncode( "Could not set x-amz-glacier-version.") & "</pre>"
    Response.End
End If

'  A hyphen selects the account belonging to the signing credentials.
'  Use the original, URL-safe vault name and IDs returned by Glacier.
success = rest.AddPathParam("{vault}","chilkat")
If (success <> 1) Then
    Response.Write "<pre>" & Server.HTMLEncode( "Could not set vault name.") & "</pre>"
    Response.End
End If

set body = Server.CreateObject("Chilkat.JsonObject")
set result = Server.CreateObject("Chilkat.JsonObject")
result.Strict = 1
set error = Server.CreateObject("Chilkat.JsonObject")
error.Strict = 1
set requestBody = Server.CreateObject("Chilkat.StringBuilder")
set responseBody = Server.CreateObject("Chilkat.StringBuilder")
success = rest.AddQueryParam("limit","50")
If (success <> 1) Then
    Response.Write "<pre>" & Server.HTMLEncode( "Could not set page limit.") & "</pre>"
    Response.End
End If

set seenMarkers = Server.CreateObject("Chilkat.Hashtable")
marker = ""
more = 1
page = 0
Do While (more = 1)
    If (page = 1000) Then
        Response.Write "<pre>" & Server.HTMLEncode( "Page limit reached; listing is incomplete.") & "</pre>"
        Response.End
    End If

    page = page + 1
    If (marker <> "") Then
        success = rest.AddQueryParam("marker",marker)
        If (success <> 1) Then
            Response.Write "<pre>" & Server.HTMLEncode( "Could not set marker.") & "</pre>"
            Response.End
        End If

    End If

    success = rest.FullRequestNoBodySb("GET","/-/vaults/{vault}/multipart-uploads",responseBody)
    If (success <> 1) Then
        Response.Write "<pre>" & Server.HTMLEncode( "Request did not complete; inspect diagnostics privately. Check state before retrying a change.") & "</pre>"
        Response.End
    End If

    If (rest.ResponseStatusCode <> 200) Then
        Response.Write "<pre>" & Server.HTMLEncode( "Glacier HTTP status: " & rest.ResponseStatusCode) & "</pre>"
        success = error.LoadSb(responseBody)
        If (success = 1) Then
            If (error.JsonTypeOf("code") = 1) Then
                Response.Write "<pre>" & Server.HTMLEncode( "AWS error code: " & error.StringOf("code")) & "</pre>"
            End If

        End If

        Response.Write "<pre>" & Server.HTMLEncode( "AWS request ID: " & rest.ResponseHdrByName("x-amzn-RequestId")) & "</pre>"
        '  Inspect full errors privately. An HTTP error is not a successful operation.
        Response.End
    End If

    success = result.LoadSb(responseBody)
    If (success <> 1) Then
        Response.Write "<pre>" & Server.HTMLEncode( "Expected valid JSON response.") & "</pre>"
        Response.End
    End If

    If (result.JsonTypeOf("UploadsList") <> 4) Then
        Response.Write "<pre>" & Server.HTMLEncode( "Missing or invalid UploadsList.") & "</pre>"
        Response.End
    End If

    i = 0
    Do While (i < result.SizeOfArray("UploadsList"))
        result.I = i
        If (result.JsonTypeOf("UploadsList[i].MultipartUploadId") <> 1) Then
            Response.Write "<pre>" & Server.HTMLEncode( "Missing or invalid UploadsList[i].MultipartUploadId.") & "</pre>"
            Response.End
        End If

        If (result.StringOf("UploadsList[i].MultipartUploadId") = "") Then
            Response.Write "<pre>" & Server.HTMLEncode( "Empty UploadsList[i].MultipartUploadId.") & "</pre>"
            Response.End
        End If

        If (result.JsonTypeOf("UploadsList[i].PartSizeInBytes") <> 2) Then
            Response.Write "<pre>" & Server.HTMLEncode( "Missing or invalid UploadsList[i].PartSizeInBytes.") & "</pre>"
            Response.End
        End If

        Response.Write "<pre>" & Server.HTMLEncode( "Upload ID: " & result.StringOf("UploadsList[i].MultipartUploadId")) & "</pre>"
        Response.Write "<pre>" & Server.HTMLEncode( "Part size: " & result.StringOf("UploadsList[i].PartSizeInBytes")) & "</pre>"
        Response.Write "<pre>" & Server.HTMLEncode( "Vault: " & result.StringOf("UploadsList[i].VaultARN")) & "</pre>"
        Response.Write "<pre>" & Server.HTMLEncode( "Created: " & result.StringOf("UploadsList[i].CreationDate")) & "</pre>"
        If (result.JsonTypeOf("UploadsList[i].ArchiveDescription") = 1) Then
            Response.Write "<pre>" & Server.HTMLEncode( "Description: " & result.StringOf("UploadsList[i].ArchiveDescription")) & "</pre>"
        End If

        i = i + 1
    Loop
    more = 0
    If (result.JsonTypeOf("Marker") = 1) Then
        marker = result.StringOf("Marker")
        If (marker = "") Then
            Response.Write "<pre>" & Server.HTMLEncode( "Empty marker; listing is incomplete.") & "</pre>"
            Response.End
        End If

        If (seenMarkers.Contains(marker) = 1) Then
            Response.Write "<pre>" & Server.HTMLEncode( "Repeated marker; listing is incomplete.") & "</pre>"
            Response.End
        End If

        success = seenMarkers.AddStr(marker,"seen")
        If (success <> 1) Then
            Response.Write "<pre>" & Server.HTMLEncode( "Could not track pagination.") & "</pre>"
            Response.End
        End If

        more = 1
    Else
        If (result.JsonTypeOf("Marker") <> 6) Then
            Response.Write "<pre>" & Server.HTMLEncode( "Missing or invalid Marker; listing is incomplete.") & "</pre>"
            Response.End
        End If

    End If

Loop
success = rest.RemoveQueryParam("limit")
If (success <> 1) Then
    Response.Write "<pre>" & Server.HTMLEncode( "Could not clear limit.") & "</pre>"
    Response.End
End If

If (marker <> "") Then
    success = rest.RemoveQueryParam("marker")
    If (success <> 1) Then
        Response.Write "<pre>" & Server.HTMLEncode( "Could not clear marker.") & "</pre>"
        Response.End
    End If

End If

Response.Write "<pre>" & Server.HTMLEncode( "Multipart upload listing complete.") & "</pre>"

%>
</body>
</html>