The document transform feature allows you to preview objects in various 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.

Parameters

Operation: imm/previewdoc

The following table describes the parameters.

Parameter Value Description
copy 0 or 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 We recommend that you use signed URLs to ensure security, regardless of whether the ACL of the source object is public read.

The process to preview an object is as follows:

  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

Assume that the requested bucket is named doc-demo and 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.

The following code provides an example on how to perform the document transform operation by using SDKs:
# Create a bucket. All object-related methods must be called through buckets.
bucket = oss2.Bucket(oss2.Auth(access_key_id, access_key_secret), endpoint, bucket_name)
# Set the parameter and sign the URL.
process = 'imm/previewdoc,copy_1'
params = {}
params.update({bucket.PROCESS: process})
url = bucket.sign_url("GET", objectKey, 3600, params=params)
# Obtain the result of the operation.
print url