Skip to content

upload_archive

upload_archive(
    vault_name: string,
    account_id: string,
    *,
    config_overrides: Optional[GlacierClientConfig] = None,
    archive_description: Optional[string] = None,
    checksum: Optional[string] = None,
    body: Optional[Body[Iterator[bytes]] | Iterator[bytes] | bytes] = None,
) -> ArchiveCreationOutput

This operation adds an archive to a vault. This is a synchronous operation, and for a successful upload, your data is durably persisted. Amazon Glacier returns the archive ID in the x-amz-archive-id header of the response.

You must use the archive ID to access your data in Amazon Glacier. After you upload an archive, you should save the archive ID returned so that you can retrieve or delete the archive later. Besides saving the archive ID, you can also index it and give it a friendly name to allow for better searching. You can also use the optional archive description field to specify how the archive is referred to in an external index of archives, such as you might create in Amazon DynamoDB. You can also get the vault inventory to obtain a list of archive IDs in a vault. For more information, see InitiateJob.

You must provide a SHA256 tree hash of the data you are uploading. For information about computing a SHA256 tree hash, see Computing Checksums.

You can optionally specify an archive description of up to 1,024 printable ASCII characters. You can get the archive description when you either retrieve the archive or get the vault inventory. For more information, see InitiateJob. Amazon Glacier does not interpret the description in any way. An archive description does not need to be unique. You cannot use the description to retrieve or sort the archive list.

Archives are immutable. After you upload an archive, you cannot edit the archive or its description.

An AWS account has full permission to perform all operations (actions). However, AWS Identity and Access Management (IAM) users don't have any permissions by default. You must grant them explicit permission to perform specific actions. For more information, see Access Control Using AWS Identity and Access Management (IAM).

For conceptual information and underlying REST API, see Uploading an Archive in Amazon Glacier and Upload Archive in the Amazon Glacier Developer Guide.

Parameters:

  • vault_name (string) –

    The name of the vault.

  • account_id (string) –

    The AccountId value is the AWS account ID of the account that owns the vault. You can either specify an AWS account ID or optionally a single '-' (hyphen), in which case Amazon Glacier uses the AWS account ID associated with the credentials used to sign the request. If you use an account ID, do not include any hyphens ('-') in the ID.

  • archive_description (Optional[string], default: None ) –

    The optional description of the archive you are uploading.

  • checksum (Optional[string], default: None ) –

    The SHA256 tree hash of the data being uploaded.

  • body (Optional[Body[Iterator[bytes]] | Iterator[bytes] | bytes], default: None ) –

    The data to upload.

Raises:

Examples:

To upload an archive The example adds an archive to a vault.

>>> client.upload_archive(vault_name='my-vault', account_id='-', archive_description='', checksum='', body='example-data-to-upload')
Source code in docs_src/capo_glacier/_services/glacier.py
def upload_archive(
    self,
    vault_name: "capo_glacier.types.string.string",
    account_id: "capo_glacier.types.string.string",
    *,
    config_overrides: Optional[GlacierClientConfig] = None,
    archive_description: Optional["capo_glacier.types.string.string"] = None,
    checksum: Optional["capo_glacier.types.string.string"] = None,
    body: Optional[Body[Iterator[bytes]] | Iterator[bytes] | bytes] = None,
) -> "capo_glacier.types.archive_creation_output.ArchiveCreationOutput":
    """<p>This operation adds an archive to a vault. This is a synchronous operation, and for a successful upload, your data is durably persisted. Amazon Glacier returns the archive ID in the <code>x-amz-archive-id</code> header of the response. </p> <p>You must use the archive ID to access your data in Amazon Glacier. After you upload an archive, you should save the archive ID returned so that you can retrieve or delete the archive later. Besides saving the archive ID, you can also index it and give it a friendly name to allow for better searching. You can also use the optional archive description field to specify how the archive is referred to in an external index of archives, such as you might create in Amazon DynamoDB. You can also get the vault inventory to obtain a list of archive IDs in a vault. For more information, see <a>InitiateJob</a>. </p> <p>You must provide a SHA256 tree hash of the data you are uploading. For information about computing a SHA256 tree hash, see <a href="https://docs.aws.amazon.com/amazonglacier/latest/dev/checksum-calculations.html">Computing Checksums</a>. </p> <p>You can optionally specify an archive description of up to 1,024 printable ASCII characters. You can get the archive description when you either retrieve the archive or get the vault inventory. For more information, see <a>InitiateJob</a>. Amazon Glacier does not interpret the description in any way. An archive description does not need to be unique. You cannot use the description to retrieve or sort the archive list. </p> <p>Archives are immutable. After you upload an archive, you cannot edit the archive or its description.</p> <p>An AWS account has full permission to perform all operations (actions). However, AWS Identity and Access Management (IAM) users don't have any permissions by default. You must grant them explicit permission to perform specific actions. For more information, see <a href="https://docs.aws.amazon.com/amazonglacier/latest/dev/using-iam-with-amazon-glacier.html">Access Control Using AWS Identity and Access Management (IAM)</a>.</p> <p> For conceptual information and underlying REST API, see <a href="https://docs.aws.amazon.com/amazonglacier/latest/dev/uploading-an-archive.html">Uploading an Archive in Amazon Glacier</a> and <a href="https://docs.aws.amazon.com/amazonglacier/latest/dev/api-archive-post.html">Upload Archive</a> in the <i>Amazon Glacier Developer Guide</i>. </p>

    Args:
        vault_name: <p>The name of the vault.</p>
        account_id: <p>The <code>AccountId</code> value is the AWS account ID of the account that owns the vault. You can either specify an AWS account ID or optionally a single '<code>-</code>' (hyphen), in which case Amazon Glacier uses the AWS account ID associated with the credentials used to sign the request. If you use an account ID, do not include any hyphens ('-') in the ID. </p>
        archive_description: <p>The optional description of the archive you are uploading.</p>
        checksum: <p>The SHA256 tree hash of the data being uploaded.</p>
        body: <p>The data to upload.</p>

    Raises:
        capo_glacier.errors.invalid_parameter_value_exception.InvalidParameterValueException: <p>Returned if a parameter of the request is incorrectly specified.</p>
        capo_glacier.errors.missing_parameter_value_exception.MissingParameterValueException: <p>Returned if a required header or parameter is missing from the request.</p>
        capo_glacier.errors.no_longer_supported_exception.NoLongerSupportedException: <p>Returned if the request was made by a customer with no Amazon Glacier storage. The request is denied as the API is no longer supported for new customers. Please use Amazon S3 Glacier storage classes instead.</p>
        capo_glacier.errors.request_timeout_exception.RequestTimeoutException: <p>Returned if, when uploading an archive, Amazon Glacier times out while receiving the upload.</p>
        capo_glacier.errors.resource_not_found_exception.ResourceNotFoundException: <p>Returned if the specified resource (such as a vault, upload ID, or job ID) doesn't exist.</p>
        capo_glacier.errors.service_unavailable_exception.ServiceUnavailableException: <p>Returned if the service cannot complete the request.</p>
        capo_glacier.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        To upload an archive
        The example adds an archive to a vault.

        >>> client.upload_archive(vault_name='my-vault', account_id='-', archive_description='', checksum='', body='example-data-to-upload')
    """

    def _handler(
        req: "OperationRequest[capo_glacier.types.upload_archive_input.UploadArchiveInput]",
    ) -> OperationResponse[
        "capo_glacier.types.archive_creation_output.ArchiveCreationOutput"
    ]:
        import capo_glacier._operations.glacier.upload_archive

        output, http_response = (
            capo_glacier._operations.glacier.upload_archive.upload_archive(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_glacier.types.upload_archive_input.UploadArchiveInput",
    ) -> dict[str, Any]:
        import capo_glacier.types.upload_archive_input

        return capo_glacier.types.upload_archive_input.redact_sensitive(input_)

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("UploadArchive", redact_input=_redact_input),
    )
    input_: capo_glacier.types.upload_archive_input.UploadArchiveInput = {
        "vault_name": vault_name,
        "account_id": account_id,
    }
    if archive_description is not None:
        input_["archive_description"] = archive_description
    if checksum is not None:
        input_["checksum"] = checksum
    if body is not None:
        input_["body"] = ensure_sync_iterator(body)

    with closing_bodies(input_):
        response = execute_pipeline(
            OperationRequest(input=input_, options=options_),
            handler=_handler,
            interceptors=list(interceptors_),
        )
        response.response.close()
        return response.output