Package Download API
Operation description
This API is in public preview. If you have any questions, join our DingTalk group to provide feedback. For the group number, see Contact us.
This API currently supports packaging but not compression. The compression feature will be added later.
-
Before using this API, make sure you understand the billing methods and pricing of Intelligent Media Management (IMM).
Important The completion time of asynchronous tasks is not guaranteed. -
File count limit: You can package up to 80,000 files.
-
File size limit: The total size of all files before packaging must not exceed 200 GB.
-
This feature supports files of the Standard storage class on OSS. To package files of other storage classes, first convert their storage class.
-
This is an asynchronous API. After a task starts, its information is stored for 7 days. After 7 days, the information can no longer be retrieved. To view task information, call the GetTask or ListTasks operation with the returned
TaskId. You can also set the Notification parameter to receive task information through asynchronous notification messages.
Try it now
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
imm:CreateFileCompressionTask |
create |
*Project
|
None | None |
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| ProjectName |
string |
Yes |
The name of the project. For more information, see Create a project. |
test-project |
| Sources |
array<object> |
No |
A list of files to package and their packaging rules. Note
Specify either this parameter or `SourceManifestURI`. `Sources` supports a maximum of 100 packaging rules. Warning If you have more than 100 packaging rules, use the `SourceManifestURI` parameter. |
|
|
object |
No |
The OSS address of a file to package and its packaging rule. |
||
| URI |
string |
No |
The OSS address of the directory or file to package. The OSS address must be in the `oss://${Bucket}/${Object}` format. `${Bucket}` is the name of the OSS bucket that is in the same region as the current project. `${Object}` is described as follows:
|
oss://test-bucket/test-object |
| Alias |
string |
No |
Specifies a new path or name for the source file within the output compressed file.
Note
|
/new-dir/ |
| Mode |
string |
No |
The pattern matching mode for the packaging rule. Valid values include
Valid values:
|
fullname |
| CredentialConfig | CredentialConfig |
No |
If you do not have special requirements, leave this parameter empty. The chained authorization configuration. This parameter is not required. For more information, see Use chained authorization to access resources of other entities. |
|
| SourceManifestURI |
string |
No |
The address where the file manifest is stored. The file manifest stores the `Sources` structure in JSON format on OSS. This is suitable for scenarios with many files to package. Note
Specify either this parameter or Warning When you save the content to OSS, specify the OSS address of the file for this parameter. The following is an example of the file structure: |
oss://test-bucket/test-object.json |
| TargetURI |
string |
Yes |
The OSS address of the output file. The compressed file is named after the file name in this path, such as The OSS address must be in the `oss://${Bucket}/${Object}` format. `${Bucket}` is the name of the OSS bucket that is in the same region as the current project. `${Object}` is the full path of the file, including the file name extension. |
oss://test-bucket/test-target-object.zip |
| CompressedFormat |
string |
No |
The compression format for file packaging. Note
Currently, only the zip format is supported. |
zip |
| UserData |
string |
No |
Custom user data. This data is returned in the asynchronous notification message, which helps you associate the notification with your internal system. The maximum length is 2,048 bytes. |
test-data |
| Notification | Notification |
No |
The message notification configuration. For more information, see the Notification data type. For the format of asynchronous notification messages, see Asynchronous notification message format. Note
IMM API callbacks do not currently support specifying a webhook address. Use MNS instead. |
Examples of packaging rules for typical scenarios
The following examples show how to configure packaging rules for typical scenarios based on the sample file structure:
(bucket)
├── test-dir1
│ ├── file1.txt
│ ├── file2.doc
│ ├── file3.png
│ └── my-file.json
└── test-dir2
├── AAA
│ └── file.txt
├── AAA
├── file6.doc
├── file7.doc
└── file8.doc
Package a specified directory
To package all files in the test-dir1 directory into a specified directory named test-dir, use the following packaging rule:
[
{
"URI" : "oss://bucket/test-dir1/",
"Alias" : "/test-dir/"
}
]
The structure of the generated compressed file is as follows:
.
└── test-dir
├── file1.txt
├── file2.doc
├── file3.png
└── my-file.json
Package files with a specified prefix
To package all files with the prefix test-dir1/file into a specified directory named test-dir, use the following packaging rule:
[
{
"URI" : "oss://bucket/test-dir1/file",
"Alias" : "/test-dir/"
}
]
The structure of the generated compressed file is as follows:
.
└── test-dir
├── file1.txt
├── file2.doc
└── file3.png
Note that if you use the prefix mode for packaging and the prefix matches both a file and a folder, both the file and the folder are packaged into the compressed file. For example:
[
{
"URI" : "oss://bucket/test-dir2/AAA",
"Alias" : "/AAA/"
}
]
The structure of the generated compressed file is as follows:
.
└── AAA
├── AAA
└── file.txt
Package specified files
If you do not want to use the prefix mode, set the mode parameter to package only specified files:
[
{
"URI" : "oss://bucket/test-dir2/AAA",
"Alias" : "AAA",
"mode" : "fullname",
},
{
"URI" : "oss://bucket/test-dir1/",
"Alias" : "/test-dir1/",
"mode" : "fullname",
}
]
The structure of the generated compressed file is as follows:
.
├── AAA
└── test-dir1
Response elements
|
Element |
Type |
Description |
Example |
|
object |
The response structure. |
||
| RequestId |
string |
The request ID. |
EC564A9A-BA5C-4499-A087-D9B9E76E***** |
| EventId |
string |
The event ID. |
0ED-1Bz8z71k5TtsUejT4UJ16Es***** |
| TaskId |
string |
The task ID. |
FileCompression-3579a380-6f7a-4a9d-b9d2-65996***** |
Examples
Success response
JSON format
{
"RequestId": "EC564A9A-BA5C-4499-A087-D9B9E76E*****",
"EventId": "0ED-1Bz8z71k5TtsUejT4UJ16Es*****",
"TaskId": "FileCompression-3579a380-6f7a-4a9d-b9d2-65996*****"
}
Error codes
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.