The document transform feature allows you to preview objects in a variety of formats, such as PPT, XLS, DOC, and PDF, to facilitate content management and access.

Note
  • To use the document transform feature, you must activate Intelligent Media Management (IMM) and bind IMM to OSS. For more information, see Quick start.
  • Document transform does not support previewing objects larger than 200 MB.

Parameter

Operation: imm/previewdoc

The following table describes the parameters that you can configure for the operation.

Parameter Valid value Description
copy 0 and 1. Default value: 1. Specifies whether the content of an object can be copied while the object is being previewed.

The value 1 indicates that the content of an object can be copied while the object is being previewed.

The value 0 indicates that the content of an object cannot be copied while the object is being previewed.

Process

Note To ensure security, we recommend that you use signed URLs regardless of whether the ACL of the source object is public read.

An object is previewed in the following process:

  1. The client initiates a preview request to the server and provides the name of the object to preview.
  2. The server signs the URL based on the request and provides the signed URL to the client.
  3. The client accesses OSS to view the object by using the signed URL.

Examples

In this example, the requested bucket named doc-demo is located in the China (Hangzhou) region. The endpoint used to access the bucket is oss-cn-hangzhou.aliyuncs.com, and the requested object is named example.docx. You can set the copy parameter to 1 to copy the content of the object under preview.
http://doc-demo.oss-cn-hangzhou.aliyuncs.com/example.docx?x-oss-process=imm/previewdoc,copy_1
You can use your AccessKey pair to sign the URL and use the signed URL for access. You can use OSS SDKs to generate a signed URL for a captured snapshot. The code used to generate signed URLs for video snapshots is similar to that used to generated signed URLs for images. You need only to change the operation performed on images in the code to snapshot. The following code uses OSS SDK for Java to provides an example on how to generate a signed URL for a captured snapshot:
// The endpoint of the China (Hangzhou) region is used in this example. Specify the actual endpoint.
String endpoint = "http://oss-cn-hangzhou.aliyuncs.com";
// Security risks may arise if you use the AccessKey pair of an Alibaba Cloud account to log on to OSS because the account has permissions on all API operations. We recommend that you use a RAM user to call API operations or perform routine operations and maintenance. To create your RAM user, log on to https://ram.console.aliyun.com.
String accessKeyId = "<yourAccessKeyId>";
String accessKeySecret = "<yourAccessKeySecret>";
String bucketName = "<yourBucketName>";
String objectName = "<yourObjectName>";
// Create an OSSClient instance.
OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
// Configure video snapshots.
String style = "imm/previewdoc,copy_1";
// Set the expiration time to 10 minutes.
Date expiration = new Date(new Date().getTime() + 1000 * 60 * 10 );
GeneratePresignedUrlRequest req = new GeneratePresignedUrlRequest(bucketName, objectName, HttpMethod.GET);
req.setExpiration(expiration);
req.setProcess(style);
URL signedUrl = ossClient.generatePresignedUrl(req);
System.out.println(signedUrl);
// Shut down the OSSClient instance.
ossClient.shutdown();
For more information about how to use OSS SDKs to generate a signed URL to process images, see: