Alibaba Cloud Object Storage Service (OSS) integrates deeply with Intelligent Media Management (IMM). This integration supports a wide range of data analytics and processing operations, such as document previews, document format conversion, facial recognition, image analysis, and QR code recognition. This topic describes how to use IMM features with OSS.
Important
New features and optimizations for Intelligent Media Management (IMM) are available only in the latest version. The previous version will be gradually phased out. For a better experience, use the Quick Start for the latest version of IMM. For a comparison of the versions, see Version guide.
Prerequisites
-
Only buckets in the China (Beijing), China (Hangzhou), China (Shanghai), China (Shenzhen), China (Zhangjiakou), and Singapore regions support IMM.
Buckets that are not region-specific do not support IMM.
-
You have activated IMM and granted the required permissions. For more information, see Activate a service and Create a project.
-
If you use a Resource Access Management (RAM) user to use IMM features, make sure the RAM user has the following permissions:
Billing
Fees are charged for creating IMM projects and using IMM features. For more information, see Billing.
Step 1: Bind IMM
Log on to the OSS console.
In the left-side navigation pane, click Buckets. On the Buckets page, find and click the desired bucket.
-
In the navigation pane on the left, choose .
-
Click Bind and select the features that you want to use.
IMM provides the following three features:
-
Document Preview: Allows you to preview documents in the bucket, such as PPT, XLS, DOC, and PDF files. For more information, see Document preview.
-
Facial Recognition: Allows you to detect faces in images in the bucket and identify their bounding boxes and attributes. For more information, see Facial recognition.
-
Image Recognition: Allows you to detect images in the bucket and identify their labels and confidence levels. For more information, see Image recognition.
-
In the Bind dialog box, in the IMM Configuration section, select one of the following binding methods:
-
Create Default Project: Enter a project name. The system automatically creates an IMM project in the region where the bucket is located and binds the project to the bucket.
-
Bind Existing Project: Select an IMM project from the drop-down list to bind to the bucket.
Important
The Bind Existing Project option is available only if an IMM project for the feature exists in the region where the bucket is located. For more information, see Create a project.
You can also click Batch Create on the Intelligent Media tab. In the Feature Configuration dialog box, specify a name for Bind Project to bind multiple IMM features at once.

This method lets you bind only automatically created IMM projects. You cannot bind existing IMM projects. If a project with the specified name already exists, the binding fails.
-
Click OK.
Step 2: Use IMM
Use the OSS console
In the left-side navigation pane, click Buckets. On the Buckets page, find and click the desired bucket.
-
In the navigation pane on the left, choose Object Management > Objects.
-
Click the name of the image or document that you want to process. In the View Details dialog box, use the IMM features.
You can also click View Details in the Actions column of the target file to open the View Details dialog box.
Use the Java SDK
The following code provides an example of how to use IMM with the OSS SDK for Java.
import com.aliyun.oss.*;
import com.aliyun.oss.common.auth.*;
import com.aliyun.oss.common.comm.SignVersion;
import com.aliyun.oss.model.GeneratePresignedUrlRequest;
import java.net.URL;
import java.util.Date;
public class Demo {
// The China (Hangzhou) region is used as an example. Specify the actual endpoint.
private static String endpoint = "https://oss-cn-hangzhou.aliyuncs.com";
// Specify the region ID that corresponds to the endpoint. For example, cn-hangzhou.
private static String region = "cn-hangzhou";
// Obtain access credentials from environment variables. Before you run this sample code, make sure that the OSS_ACCESS_KEY_ID and OSS_ACCESS_KEY_SECRET environment variables are configured.
static EnvironmentVariableCredentialsProvider credentialsProvider;
static {
try {
credentialsProvider = CredentialsProviderFactory.newEnvironmentVariableCredentialsProvider();
} catch (com.aliyuncs.exceptions.ClientException e) {
e.printStackTrace();
}
}
// Specify the bucket name. For example, examplebucket.
private static String bucketName = "examplebucket";
// Specify the full path of the object. The full path cannot contain the bucket name.
private static String objectKey = "example.jpg";
public static void main(String[] args) {
// Obtain the signed URL for facial recognition on the object.
URL url = getUrl("imm/detectface", bucketName, objectKey);
customerPrint(url);
bucketName = "examplebucket";
objectKey = "example.txt";
// Obtain the signed URL for document preview of the object.
url = getUrl("imm/previewdoc", bucketName, objectKey);
customerPrint(url);
}
private static void customerPrint(URL url){
if(url != null){
System.out.println(url.toString());
}else{
System.out.println("Failed to obtain the URL.");
}
}
private static URL getUrl(String process, String bucketName, String objectKey) {
// Create an OSSClient instance.
// When the OSSClient instance is no longer used, call the shutdown method to release resources.
ClientBuilderConfiguration clientBuilderConfiguration = new ClientBuilderConfiguration();
// Explicitly declare the use of the V4 signature algorithm.
clientBuilderConfiguration.setSignatureVersion(SignVersion.V4);
OSS ossClient = OSSClientBuilder.create()
.endpoint(endpoint)
.credentialsProvider(credentialsProvider)
.clientConfiguration(clientBuilderConfiguration)
.region(region)
.build();
try {
GeneratePresignedUrlRequest request = new GeneratePresignedUrlRequest(bucketName, objectKey);
request.setProcess(process);
// Set the expiration time of the signed URL. Unit: milliseconds.
request.setExpiration(new Date(new Date().getTime() + 3600 * 1000));
return ossClient.generatePresignedUrl(request);
} catch (OSSException oe) {
System.out.println("Error Message:" + oe.getErrorMessage());
System.out.println("Error Code:" + oe.getErrorCode());
System.out.println("Request ID:" + oe.getRequestId());
System.out.println("Host ID:" + oe.getHostId());
} catch (ClientException ce) {
System.out.println("Error Message:" + ce.getMessage());
} finally {
// Shut down the OSSClient instance.
ossClient.shutdown();
}
return null;
}
}
(Optional) Unbind IMM
If you no longer need to use IMM features, unbind IMM from the bucket to avoid unnecessary fees.
In the left-side navigation pane, click Buckets. On the Buckets page, find and click the desired bucket.
-
In the navigation pane on the left, choose .
-
To the right of the IMM feature that you want to unbind, choose
> Unbind.
-
Click OK.