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.
- 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.
The following table describes the parameters that you can configure for the operation.
|copy||0 and 1. Default value: 1.||Specifies whether the content of an object can be copied while the object is being
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.
An object is previewed in the following process:
- The client initiates a preview request to the server and provides the name of the object to preview.
- The server signs the URL based on the request and provides the signed URL to the client.
- The client accesses OSS to view the object by using the signed URL.
// 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();