tencent cloud

Cloud Object Storage

Release Notes and Announcements
Release Notes
Announcements
Product Introduction
Overview
Features
Use Cases
Strengths
Concepts
Regions and Access Endpoints
Specifications and Limits
Service Regions and Service Providers
Billing
Billing Overview
Billing Method
Billable Items
Free Tier
Billing Examples
Viewing and Downloading Bill
Payment Overdue
FAQs
Getting Started
Console
Getting Started with COSBrowser
User Guide
Creating Request
Bucket
Object
Data Management
Batch Operation
Global Acceleration
Monitoring and Alarms
Operations Center
Data Processing
Content Moderation
Smart Toolbox
Data Processing Workflow
Application Integration
User Tools
Tool Overview
Installation and Configuration of Environment
COSBrowser
COSCLI (Beta)
COSCMD
COS Migration
FTP Server
Hadoop
COSDistCp
HDFS TO COS
GooseFS-Lite
Online Tools
Diagnostic Tool
Use Cases
Overview
Access Control and Permission Management
Performance Optimization
Accessing COS with AWS S3 SDK
Data Disaster Recovery and Backup
Domain Name Management Practice
Image Processing
Audio/Video Practices
Workflow
Direct Data Upload
Content Moderation
Data Security
Data Verification
Big Data Practice
COS Cost Optimization Solutions
Using COS in the Third-party Applications
Migration Guide
Migrating Local Data to COS
Migrating Data from Third-Party Cloud Storage Service to COS
Migrating Data from URL to COS
Migrating Data Within COS
Migrating Data Between HDFS and COS
Data Lake Storage
Cloud Native Datalake Storage
Metadata Accelerator
GooseFS
Data Processing
Data Processing Overview
Image Processing
Media Processing
Content Moderation
File Processing Service
File Preview
Troubleshooting
Obtaining RequestId
Slow Upload over Public Network
403 Error for COS Access
Resource Access Error
POST Object Common Exceptions
API Documentation
Introduction
Common Request Headers
Common Response Headers
Error Codes
Request Signature
Action List
Service APIs
Bucket APIs
Object APIs
Batch Operation APIs
Data Processing APIs
Job and Workflow
Content Moderation APIs
Cloud Antivirus API
SDK Documentation
SDK Overview
Preparations
Android SDK
C SDK
C++ SDK
.NET(C#) SDK
Flutter SDK
Go SDK
iOS SDK
Java SDK
JavaScript SDK
Node.js SDK
PHP SDK
Python SDK
React Native SDK
Mini Program SDK
Error Codes
Harmony SDK
Endpoint SDK Quality Optimization
Security and Compliance
Data Disaster Recovery
Data Security
Cloud Access Management
FAQs
Popular Questions
General
Billing
Domain Name Compliance Issues
Bucket Configuration
Domain Names and CDN
Object Operations
Logging and Monitoring
Permission Management
Data Processing
Data Security
Pre-signed URL Issues
SDKs
Tools
APIs
Agreements
Service Level Agreement
Privacy Policy
Data Processing And Security Agreement
Contact Us
Glossary

Sync Request API

PDF
Mode fokus
Ukuran font
Terakhir diperbarui: 2026-01-13 16:34:01

Overview

The file preview feature allows generating images from multiple types of files for preview and performing basic processing operations on the output images synchronously. It addresses the display problems of file content on webpages and enables easy online file preview on PC, app, and other terminals. It is widely suitable for diverse business scenarios, such as online education, enterprise OA, and website transcoding.
Note:
To use this feature, you need to click File Processing on the management page of a bucket in the CI console, find the File Preview configuration item, and toggle it on. Then, you can call a specific file preview API to preview files in the bucket synchronously or asynchronously.
File preview is a paid feature. For billing details, see File Processing Fees.Upon the initial generation of document preview to image usage in each account, Cloud Infinite will issue a free quota resource package for document preview to image conversion, encompassing 6000 pages and valid for two months. Normal billing will commence once the usage exceeds the quota or the resource package expires.
The conversion logic of file transcoding is the same as that of local printing. If you need to change the conversion orientation (such as outputting an Excel file with many columns horizontally to one page), you need to change the source file print settings.

Request

Sample request

GET /<ObjectKey>?ci-process=doc-preview&page=<page>&srcType=<srcType>&ImageParams=<ImageParams> HTTP/1.1
Host: <BucketName-APPID>.cos.<Region>.myqcloud.com
Date: GMT Date
Authorization: Auth String
Note:
Authorization: Auth String (See Request Signature for details.)
When this feature is used by a sub-account, relevant permissions must be granted as instructed in Authorization Granularity Details.
For private buckets, the request needs to carry the signature for file download.

Request headers

This API only uses Common Request Headers.

Common request parameters

Parameter
Description
Type
Required
ObjectKey
Object name, such as folder/document.pdf.
String
Yes
ci-process
CI's processing capability, which is fixed at doc-preview for file preview.
String
Yes
srcType
Source data type. Currently, the file conversion feature determines the source data type according to the file extension of the COS object. If the object has no extension, you can set this value.
String
No
page
Number of the page to be converted, which is counted from 1 by default. For spreadsheets, page indicates to convert the xth image in the xth sheet.
Int
No
dstType
Type of the output target file. Valid values:
png
jpg
pdf (the page number cannot be selected, and the page parameter does not take effect)
If the input file format cannot be recognized, the jpg format will be used by default.
String
No
password
Password to open the Office file. If you need to convert a password-protected file, set this field.
String
No
comment
Whether to hide comments and apply track changes. 0: hide comments and apply track changes; 1: show comments and track changes. Default value: 0.
Int
No

Parameters for spreadsheet files (Excel)

Header
Description
Type
Required
sheet
Sheet parameter, indicating to convert the xth sheet. Default value: 1.
Int
No
excelPaperDirection
Paper orientation of the spreadsheet. 0: vertical; other values: horizontal. Default value: 0.
Int
No
excelPaperSize
Paper (canvas) size. Valid values: 0 (A4), 1 (A2), 2 (A0). Default value: 0. This parameter should be used together with excelRow or excelCol.
Int
No

Parameters for transcoding to .png/.jpg images

Name
Description
Type
Required
ImageParams
Processing parameters for the output image. All parameters of basic image processing are supported. To specify multiple parameters, separate them with pipeline operators. In this way, the image can be processed by multiple parameters in sequence in the same request.
String
No
quality
Quality of the generated preview image. Value range: [1, 100]. Default value: 100. For example, if the value is 100, the quality of the generated image will be 100%.
Int
No
scale
Scaling parameter of the preview image. Value range: [10, 200]. Default value: 100. For example, if the value is 200, the image will be scaled up (enlarged) by 200%.
Int
No
imageDpi
Renders the image based on the specified DPI. This parameter works together with scale. Value range: 96–600. Default value: 96. The width of the output image must be less than 65500 px.
Int
No
Note:
Currently supported input file types include:
Presentation files: PPTX, PPT, POT, POTX, PPS, PPSX, DPS, DPT, PPTM, POTM, PPSM.
Text files: DOC, DOT, WPS, WPT, DOCX, DOTX, DOCM, DOTM.
Spreadsheet files: XLS, XLT, ET, ETT, XLSX, XLTX, CSV, XLSB, XLSM, XLTM, ETS. A spreadsheet file may be split into multiple pages, with multiple images generated.
Other files: PDF, LRC, C, CPP, H, ASM, S, JAVA, ASP, BAT, BAS, PRG, CMD, RTF, TXT, LOG, XML, HTM, HTML.
The input file size cannot exceed 200 MB.
The number of pages in the input file cannot exceed 5,000.
The synchronous interface is suitable for PDF files within a hundred pages or for previewing a few pages. For larger files, it is recommended to utilize the asynchronous interface.

Request body

The request body of this request is empty.

Response

Response headers

This API only returns Common Response Headers.

Response parameter description

Parameter
Description
Type
X-Total-Page
Total number of pages in the file (or images converted from sheets in the spreadsheet file) returned in the HTTP header. This value will be empty in case of an exception.
Int
Content-Type
Different values will be returned based on the actual image format, such as image/jpeg and image/webp.
String
X-ErrNo
The error code returned in case of an exception, which can be viewed in the HTTP header.
String
X-Total-Sheet
Total number of sheets in the spreadsheet file returned in the HTTP header.
Int
X-Sheet-Name
Name of the current sheet in the spreadsheet file returned in the HTTP header.
String

Error codes

No special error message will be returned for this request. For the common error messages, please see Error Codes.

Examples

Sample 1: Previewing a general file

Request

GET /sample.pdf?ci-process=doc-preview&page=1 HTTP/1.1
Host: examplebucket-1250000000.cos.ap-shanghai.myqcloud.com

Response 1: Preview succeeds

HTTP/1.1 200 OK
Content-Type: image/jpeg
Content-Length: 645
Date: Tue, 03 Apr 2018 09:06:16 GMT
X-Total-Page: 100

[Image data after transcoding]

Response 2: The file does not exist

HTTP/1.1 404 OK
Connection: close
Content-Length: 455
Content-Type: application/xml
Date: Thu, 09 Apr 2020 13:44:52 GMT
X-ErrNo: -3004

Response 3: The specified page does not exist

HTTP/1.1 404 OK
Connection: close
Content-Length: 455
Content-Type: application/xml
Date: Thu, 09 Apr 2020 13:44:52 GMT
X-ErrNo: -3013
Sample 2: Previewing a file and processing the image by scaling it and adding a text watermark

Request

GET /sample.pdf?ci-process=doc-preview&page=1&ImageParams=imageMogr2/thumbnail/!50p|watermark/2/text/5pWw5o2u5LiH6LGh/fill/I0ZGRkZGRg==/fontsize/30/dx/20/dy/20 HTTP/1.1
Host: examplebucket-1250000000.cos.ap-shanghai.myqcloud.com

Response 1: Preview succeeds

HTTP/1.1 200 OK
Content-Type: image/jpeg
Content-Length: 645
Date: Tue, 03 Apr 2018 09:06:16 GMT
X-Total-Page: 100

[Image data after transcoding]

Response 2: The file does not exist

HTTP/1.1 404 OK
Connection: close
Content-Length: 455
Content-Type: application/xml
Date: Thu, 09 Apr 2020 13:44:52 GMT
X-ErrNo: -3004

Response 3: The specified page does not exist

HTTP/1.1 404 OK
Connection: close
Content-Length: 455
Content-Type: application/xml
Date: Thu, 09 Apr 2020 13:44:52 GMT
X-ErrNo: -3013


Bantuan dan Dukungan

Apakah halaman ini membantu?

masukan