All Products
Search
Document Center

Intelligent Media Management:Package file decompression

Last Updated:Jul 01, 2025

This topic describes how to use Intelligent Media Management (IMM) to compress one or more objects stored in Object Storage Service (OSS), query file content in a package, and decompress a package. Compression and decompression are useful in many scenarios, such as data transmission, backup, and archiving. You can use compression and decompression to efficiently manage and process data in a bucket. For example, you can use this feature to improve data transmission speed, reduce storage usage, and facilitate data archiving and sharing.

Feature overview

IMM supports compression and decompression of files in the cloud, which improves efficiency and simplifies file management. You can use IMM to compress and decompress objects online in OSS.

Prerequisites

  • An AccessKey pair is created and obtained. For more information, see Create an AccessKey pair.

  • OSS is activated, a bucket is created, and objects are uploaded to the bucket. For more information, see Upload objects.

  • IMM is activated. For more information, see Activate IMM.

  • A project is created in the IMM console. For more information about how to create a project by using the IMM console, see Create a project.

    Note
    • You can also call the CreateProject operation to create a project. For more information, see CreateProject.

    • You can call the ListProjects operation to query existing projects in a specific region. For more information, see ListProjects.

Supported formats

  • The compression feature only supports packaging operations.

  • The compression feature only supports the ZIP format.

  • The decompression and package preview features support ZIP, RAR, and 7z formats.

Notes

Information of compression, package read, and decompression tasks is retained for 7 days after the task start date and cannot be queried after the 7-day window ends. You can use one of the following methods to query task information:

Compression

Call the CreateFileCompressionTask - Create a file compression task operation to compress multiple objects in an OSS bucket.

Compression information

  • IMM project: test-project

  • Objects to compress:

    • oss://test-bucket/test-object1.jpg

    • oss://test-bucket/test-object2.jpg

    • oss://test-bucket/test-object3.jpg

    • oss://test-bucket/test-object4.jpg

  • Output path: oss://test-bucket/test-target-object.zip

Request example

{
    "ProjectName": "test-project",
    "CompressedFormat": "zip",
    "Sources": "[{\"URI\":\"oss://test-bucket/test-object1.jpg\"},{\"URI\":\"oss://test-bucket/test-object2.jpg\"},{\"URI\":\"oss://test-bucket/test-object3.jpg\"},{\"URI\":\"oss://test-bucket/test-object4.jpg\"}]",
    "TargetURI": "oss://test-bucket/test-target-object.zip"
}

Response example

{
  "TaskId": "FileCompression-7e3e2b8c-81bd-495f-a338-25b3762a****",
  "RequestId": "C54C5888-9C96-5A35-AF73-ABD6EF15****",
  "EventId": "164-1S6uXTYhUU4qAFCPOTcYdcb****"
}

Sample code

The following sample code provides an example on how to compress multiple objects:

# -*- coding: utf-8 -*-
# This file is auto-generated, don't edit it. Thanks.
import os
import sys

from typing import List

from alibabacloud_imm20200930.client import Client as imm20200930Client
from alibabacloud_tea_openapi import models as open_api_models
from alibabacloud_imm20200930 import models as imm_20200930_models
from alibabacloud_tea_util import models as util_models
from alibabacloud_tea_util.client import Client as UtilClient


class Sample:
    def __init__(self):
        pass

    @staticmethod
    def create_client(
        access_key_id: str,
        access_key_secret: str,
    ) -> imm20200930Client:
        """
        Use your AccessKey ID and AccessKey secret to initialize the client.
        @param access_key_id:
        @param access_key_secret:
        @return: Client
        @throws Exception
        """
        config = open_api_models.Config(
            access_key_id=access_key_id,
            access_key_secret=access_key_secret
        )
        # Specify the IMM endpoint.
        config.endpoint = f'imm.cn-beijing.aliyuncs.com'
        return imm20200930Client(config)

    @staticmethod
    def main(
        args: List[str],
    ) -> None:
        # The AccessKey pair of an Alibaba Cloud account has permissions on all API operations. Using these credentials to perform operations is a high-risk operation. We recommend that you use a RAM user to call API operations or perform routine O&M.
        # We recommend that you do not include your AccessKey pair (AccessKey ID and AccessKey secret) in your project code for data security reasons.
        # In this example, the AccessKey pair is read from the environment variables to implement identity verification for API access.
        imm_access_key_id = os.getenv("AccessKeyId")
        imm_access_key_secret = os.getenv("AccessKeySecret")
        client = Sample.create_client(imm_access_key_id, imm_access_key_secret)
        sources_0 = imm_20200930_models.CreateFileCompressionTaskRequestSources(
            uri='oss://test-bucket/test-object1.jpg'
        )
        sources_1 = imm_20200930_models.CreateFileCompressionTaskRequestSources(
            uri='oss://test-bucket/test-object2.jpg'
        )
        sources_2 = imm_20200930_models.CreateFileCompressionTaskRequestSources(
            uri='oss://test-bucket/test-object3.jpg'
        )
        sources_3 = imm_20200930_models.CreateFileCompressionTaskRequestSources(
            uri='oss://test-bucket/test-object4.jpg'
        )
        create_file_compression_task_request = imm_20200930_models.CreateFileCompressionTaskRequest(
            project_name='test-project',
            sources=[
                sources_0,
                sources_1,
                sources_2,
                sources_3
            ],
            target_uri='oss://test-bucket/test-target-object.zip',
            compressed_format='zip',
        )
        runtime = util_models.RuntimeOptions()
        try:
            # Write your code to print the response of the API operation if necessary.
            client.create_file_compression_task_with_options(create_file_compression_task_request, runtime)
        except Exception as error:
            # Print the error message if necessary.
            UtilClient.assert_as_string(error.message)

    @staticmethod
    async def main_async(
        args: List[str],
    ) -> None:
        # The AccessKey pair of an Alibaba Cloud account has permissions on all API operations. Using these credentials to perform operations is a high-risk operation. We recommend that you use a RAM user to call API operations or perform routine O&M.
        # We recommend that you do not include your AccessKey pair (AccessKey ID and AccessKey secret) in your project code for data security reasons.
        # In this example, the AccessKey pair is read from the environment variables to implement identity verification for API access.
        imm_access_key_id = os.getenv("AccessKeyId")
        imm_access_key_secret = os.getenv("AccessKeySecret")
        client = Sample.create_client(imm_access_key_id, imm_access_key_secret)
        sources_0 = imm_20200930_models.CreateFileCompressionTaskRequestSources(
            uri='oss://test-bucket/test-object1.jpg'
        )
        sources_1 = imm_20200930_models.CreateFileCompressionTaskRequestSources(
            uri='oss://test-bucket/test-object2.jpg'
        )
        sources_2 = imm_20200930_models.CreateFileCompressionTaskRequestSources(
            uri='oss://test-bucket/test-object3.jpg'
        )
        sources_3 = imm_20200930_models.CreateFileCompressionTaskRequestSources(
            uri='oss://test-bucket/test-object4.jpg'
        )
        create_file_compression_task_request = imm_20200930_models.CreateFileCompressionTaskRequest(
            project_name='test-project',
            sources=[
                sources_0,
                sources_1,
                sources_2,
                sources_3
            ],
            target_uri='oss://test-bucket/test-target-object.zip',
            compressed_format='zip',
        )
        runtime = util_models.RuntimeOptions()
        try:
            # Write your code to print the response of the API operation if necessary.
            await client.create_file_compression_task_with_options_async(create_file_compression_task_request, runtime)
        except Exception as error:
            # Print the error message if necessary.
            UtilClient.assert_as_string(error.message)


if __name__ == '__main__':
    Sample.main(sys.argv[1:])

Query package content

Call the CreateArchiveFileInspectionTask - Create a package parsing task operation to query the content of a package in OSS.

Package information

  • Project name: test-project

  • Path of the package: oss://test-bucket/test-target-object.zip

  • Output path: oss://test-bucket/test-target-object.json

Request example

{
    "ProjectName": "test-project",
    "SourceURI": "oss://test-bucket/test-target-object.zip",
    "TargetURI": "oss://test-bucket/test-target-object.json"
}

Response example

{
    "TaskId": "ArchiveFileInspection-4a7c308a-5671-4d34-ba41-86a942d0****",
    "RequestId": "20D23855-C9E6-5193-8939-3A8797E1****",
    "EventId": "2AB-1S53L6FTdU6yMxkc1JgpwcV****"
}

Sample code

The following sample code provides an example on how to query the content of a package:

# -*- coding: utf-8 -*-
# This file is auto-generated, don't edit it. Thanks.
import os
import sys

from typing import List

from alibabacloud_imm20200930.client import Client as imm20200930Client
from alibabacloud_tea_openapi import models as open_api_models
from alibabacloud_imm20200930 import models as imm_20200930_models
from alibabacloud_tea_util import models as util_models
from alibabacloud_tea_util.client import Client as UtilClient


class Sample:
    def __init__(self):
        pass

    @staticmethod
    def create_client(
        access_key_id: str,
        access_key_secret: str,
    ) -> imm20200930Client:
        """
        Use your AccessKey ID and AccessKey secret to initialize the client.
        @param access_key_id:
        @param access_key_secret:
        @return: Client
        @throws Exception
        """
        config = open_api_models.Config(
            access_key_id=access_key_id,
            access_key_secret=access_key_secret
        )
        # Specify the IMM endpoint.
        config.endpoint = f'imm.cn-beijing.aliyuncs.com'
        return imm20200930Client(config)

    @staticmethod
    def main(
        args: List[str],
    ) -> None:
        # The AccessKey pair of an Alibaba Cloud account has permissions on all API operations. Using these credentials to perform operations is a high-risk operation. We recommend that you use a RAM user to call API operations or perform routine O&M.
        # We recommend that you do not include your AccessKey pair (AccessKey ID and AccessKey secret) in your project code for data security reasons.
        # In this example, the AccessKey pair is read from the environment variables to implement identity verification for API access.
        imm_access_key_id = os.getenv("AccessKeyId")
        imm_access_key_secret = os.getenv("AccessKeySecret")
        client = Sample.create_client(imm_access_key_id, imm_access_key_secret)
        create_archive_file_inspection_task_request = imm_20200930_models.CreateArchiveFileInspectionTaskRequest(
            project_name='test-project',
            source_uri='oss://test-bucket/test-target-object.zip',
            target_uri='oss://test-bucket/test-target-object.json'
        )
        runtime = util_models.RuntimeOptions()
        try:
            # You can choose to print the response of the API operation.
            client.create_archive_file_inspection_task_with_options(create_archive_file_inspection_task_request, runtime)
        except Exception as error:
            # Print the error message if necessary.
            UtilClient.assert_as_string(error.message)

    @staticmethod
    async def main_async(
        args: List[str],
    ) -> None:
        # The AccessKey pair of an Alibaba Cloud account has permissions on all API operations. Using these credentials to perform operations is a high-risk operation. We recommend that you use a RAM user to call API operations or perform routine O&M.
        # We recommend that you do not include your AccessKey pair (AccessKey ID and AccessKey secret) in your project code for data security reasons.
        # In this example, the AccessKey pair is read from the environment variables to implement identity verification for API access.
        imm_access_key_id = os.getenv("AccessKeyId")
        imm_access_key_secret = os.getenv("AccessKeySecret")
        client = Sample.create_client(imm_access_key_id, imm_access_key_secret)
        create_archive_file_inspection_task_request = imm_20200930_models.CreateArchiveFileInspectionTaskRequest(
            project_name='test-project',
            source_uri='oss://test-bucket/test-target-object.zip',
            target_uri='oss://test-bucket/test-target-object.json',
        )
        runtime = util_models.RuntimeOptions()
        try:
            # You can choose to print the response of the API operation.
            await client.create_archive_file_inspection_task_with_options_async(create_archive_file_inspection_task_request, runtime)
        except Exception as error:
            # Print the error message if necessary.
            UtilClient.assert_as_string(error.message)


if __name__ == '__main__':
    Sample.main(sys.argv[1:])

Decompression

Call the CreateFileUncompressionTask - Create a decompression task operation to decompress a package in OSS.

Decompression information

  • Project name: test-project

  • Path of the package: oss://test-bucket/test-target-object.zip

  • Object to decompress: test-object1.jpg

  • Output path: oss://test-bucket/test-target-object

Request example

{
    "ProjectName": "test-project",
    "SourceURI": "oss://test-bucket/test-target-object.zip",
    "Target": "{\"URI\":\"oss://test-bucket/test-target-object\"}",
    "SelectedFiles": "[\"test-object1.jpg\"]"
}

Response example

{
  "TaskId": "FileUncompression-f31061ab-eaeb-469d-ac8f-9af10e5d****",
  "RequestId": "20115435-9F59-58C0-8D15-E6ECC096****",
  "EventId": "3B6-1S6ywKAB2ogXJnrzmk6tFUF****"
}

Sample code

The following sample code provides an example on how to decompress a package:

# -*- coding: utf-8 -*-
# This file is auto-generated, don't edit it. Thanks.
import os
import sys

from typing import List

from alibabacloud_imm20200930.client import Client as imm20200930Client
from alibabacloud_tea_openapi import models as open_api_models
from alibabacloud_imm20200930 import models as imm_20200930_models
from alibabacloud_tea_util import models as util_models
from alibabacloud_tea_util.client import Client as UtilClient


class Sample:
    def __init__(self):
        pass

    @staticmethod
    def create_client(
            access_key_id: str,
            access_key_secret: str,
    ) -> imm20200930Client:
        """
        Use your AccessKey ID and AcecssKey secret to initialize the client.
        @param access_key_id:
        @param access_key_secret:
        @return: Client
        @throws Exception
        """
        config = open_api_models.Config(
            access_key_id=access_key_id,
            access_key_secret=access_key_secret
        )
        # The endpoint.
        config.endpoint = f'imm.cn-beijing.aliyuncs.com'
        return imm20200930Client(config)

    @staticmethod
    def main(
            args: List[str],
    ) -> None:
        # The AccessKey pair of an Alibaba Cloud account has permissions on all API operations. Using these credentials to perform operations is a high-risk operation. We recommend that you use a RAM user to call API operations or perform routine O&M.
        # We recommend that you do not include your AccessKey pair (AccessKey ID and AccessKey secret) in your project code for data security reasons.
        # In this example, the AccessKey pair is read from the environment variables to implement identity verification for API access.
        imm_access_key_id = os.getenv("AccessKeyId")
        imm_access_key_secret = os.getenv("AccessKeySecret")
        client = Sample.create_client(imm_access_key_id, imm_access_key_secret)
        target = imm_20200930_models.CreateFileUncompressionTaskRequestTarget(
            uri='oss://test-bucket/test'
        )
        create_file_uncompression_task_request = imm_20200930_models.CreateFileUncompressionTaskRequest(
            project_name='test-project',
            target=target,
            source_uri='oss://test-bucket/test-target-object.zip'
        )
        runtime = util_models.RuntimeOptions()
        try:
            # Write code to print the response of the API operation based on your business requirements.
            response = client.create_file_uncompression_task_with_options(create_file_uncompression_task_request, runtime)
        except Exception as error:
            # You can choose to print the error if necessary.
            UtilClient.assert_as_string(error.message)

    @staticmethod
    async def main_async(
            args: List[str],
    ) -> None:
        # The AccessKey pair of an Alibaba Cloud account has permissions on all API operations. Using these credentials to perform operations is a high-risk operation. We recommend that you use a RAM user to call API operations or perform routine O&M.
        # We recommend that you do not include your AccessKey pair (AccessKey ID and AccessKey secret) in your project code for data security reasons.
        # In this example, the AccessKey pair is read from the environment variables to implement identity verification for API access.
        imm_access_key_id = os.getenv("AccessKeyId")
        imm_access_key_secret = os.getenv("AccessKeySecret")
        client = Sample.create_client(imm_access_key_id, imm_access_key_secret)
        target = imm_20200930_models.CreateFileUncompressionTaskRequestTarget(
            uri='oss://test-bucket/test'
        )
        create_file_uncompression_task_request = imm_20200930_models.CreateFileUncompressionTaskRequest(
            project_name='test-project',
            target=target,
            source_uri='oss://test-bucket/test-target-object.zip'
        )
        runtime = util_models.RuntimeOptions()
        try:
            # Write code to print the response of the API operation based on your business requirements.
            await client.create_file_uncompression_task_with_options_async(create_file_uncompression_task_request, runtime)
        except Exception as error:
            # You can choose to print the error if necessary.
            UtilClient.assert_as_string(error.message)


if __name__ == '__main__':
    Sample.main(sys.argv[1:])

Billing

During package file decompression, the following billing items are generated on the OSS and IMM sides:

  • OSS side: For more information about pricing, see OSS Pricing.

    API

    Billing item

    Description

    GetObject

    GET requests

    You are charged request fees based on the number of successful requests.

    outbound traffic over Internet

    If you call the GetObject operation by using a public endpoint, such as oss-cn-hangzhou.aliyuncs.com, or an acceleration endpoint, such as oss-accelerate.aliyuncs.com, you are charged fees for outbound traffic over the Internet based on the data size.

    Retrieval of IA objects

    If IA objects are retrieved, you are charged IA data retrieval fees based on the size of retrieved IA objects.

    Data Retrieval Capacity from Archive Direct Read

    If Archive objects in a bucket for which real-time access is enabled are retrieved, You are charged Archive data retrieval fees based on the size of retrieved Archive objects.

    Transfer acceleration

    If you enable transfer acceleration and use an acceleration endpoint to access your bucket, you are charged transfer acceleration fees based on the data size.

  • IMM side: For more information about pricing, see IMM billing items.

    Important

    Starting from 11:00 on July 28, 2025 (UTC+8), IMM file compression and decompression services will be upgraded from a free model to a paid model. For more information, see IMM billing adjustment announcement.

    API

    Billing item

    Description

    CreateFileCompressionTask

    FileProcess

    You are charged compression fees based on the size of source files to compress.

    CreateFileUncompressionTask

    You are charged decompression fees based on the size of decompressed files.

    CreateArchiveFileInspectionTask

    FilePreview

    You are charged preview fees based on the size of the package to preview.

FAQ