Smart document summarization automatically condenses long documents into brief summaries that highlight key points of the documents. This process saves readers the effort of reading the full documents and enables them to quickly grasp the content.
Prerequisites
The corresponding Object Storage Service (OSS) bucket is bound to an Intelligent Media Management (IMM) project. For more information about how to bind an OSS bucket to an IMM project in the OSS console, see Quick start. For more information about how to bind an OSS bucket to an IMM project by using the IMM API, see AttachOSSBucket.
Usage notes
Intelligent document summarization supports only synchronous processing (x-oss-process).
To use the intelligent document summarization feature, you must use the POST method to send requests.
Anonymous access will be denied.
You must have the required permissions to use the feature. For more information, see permissions.
Parameters
Action: doc/summarize
The following table describes the parameters that you can specify when you use the intelligent document summarization feature.
Parameter | Type | Required | Description |
content | string | Yes | The content that you want to summarize. The content must be encoded in URL-safe Base64. Note The content can be up to 19,500 bytes in length. |
format | string | No | The mode to return the response. Valid values:
|
The following table describes the response parameters.
Parameter | Type | Description |
RequestId | string | The request ID. |
Output | struct | The output. Child nodes: Text and FinishReason |
Text | string | The summary. Parent node: Output |
FinishReason | string | The status of the summarization task. Valid values:
Parent node: Output |
Use the RESTful API
If you use the RESTful API to summarize a document, you must specify the document name, which is used only as a placeholder. Intelligent document summarization only identifies the value of the content parameter as the text to be summarized.
Summarize documents in regular mode
Processing method
Document to be processed: example.doc
Text to be summarized: Ernest Hemingway's "The Old Man and the Sea" is a tale of an old fisherman, Santiago, and his epic struggle to catch a giant marlin. This story is a profound exploration of human endurance, perseverance, and the battle against the forces of nature. Santiago's unwavering determination and dignity in the face of adversity serve as a testament to the strength of the human spirit.
Response format: JSON
Sample request
POST /example.doc?x-oss-process HTTP/1.1
Host: doc-demo.oss-cn-hangzhou.aliyuncs.com
Date: Fri, 28 Oct 2022 06:40:10 GMT
Authorization: OSS4-HMAC-SHA256 Credential=LTAI********************/20250417/cn-hangzhou/oss/aliyun_v4_request,Signature=a7c3554c729d71929e0b84489addee6b2e8d5cb48595adfc51868c299c0c218e
x-oss-process=doc/summarize,content__5Zub5aSn5ZCN6JGX77yM6KKr6KqJ5Li65Lit5Zu95paH5a2m5a6d5bqT5Lit55qE55KA55Ko5piO54-g77yM5piv5Lit5Zu95Y-k5Luj5bCP6K-06Im65pyv5beF5bOw55qE6LGh5b6B44CC6L-Z5Zub6YOo5Li-5LiW6Ze75ZCN55qE5bCP6K-05beo6JGX77yM5YiG5Yir5piv572X6LSv5Lit5omA5Yib5L2c55qE5Y6G5Y-y6aKY5p2Q5bCP6K-044CK5LiJ5Zu95ryU5LmJ44CL77yM5ZC05om_5oGp56yU5LiL55qE56We6a2U5aWH5bm75L2c5ZOB44CK6KW_5ri46K6w44CL77yM5pa96ICQ5bq15Yib5L2c55qE6Iux6ZuE5Lyg5aWH5bCP6K-044CK5rC05rWS5Lyg44CL77yM5Lul5Y-K5pu56Zuq6Iq55pKw5YaZ55qE5Lq65oOF5LiW5pWF5LiO5a625peP5YW06KGw55qE57uP5YW45LmL5L2c44CK57qi5qW85qKm44CL44CC44CK5LiJ5Zu95ryU5LmJ44CL5Lul5Lic5rGJ5pyr5bm05Y-K5LiJ5Zu95pe25Luj5Li66IOM5pmv77yM55Sf5Yqo5o-P57uY5LqG576k6ZuE5LqJ6Zy455qE5Y6G5Y-y55S75Y2377yb44CK6KW_5ri46K6w44CL5YiZ5Lul5ZSQ5YOn5biI5b6S5Y-W57uP55qE5pWF5LqL5Li65Li757q_77yM6J6N5ZCI5LqG5aSn6YeP55qE56We6K-d5Lyg6K-05ZKM5rCR6Ze05pWF5LqL77yM5bGV546w5Ye65LiA5bmF55Gw5Li95aWH54m555qE56We6a2U5LiW55WM77yb44CK5rC05rWS5Lyg44CL6K6y6L-w5LqG5YyX5a6L5pyr5bm05qKB5bGx5aW95rGJ5Lus5Y-N5oqX5bCB5bu657uf5rK76ICF55qE5aOu5Li95Y-y6K-X77yM5bGV546w5LqG6I2J6I696Iux6ZuE5Lus55qE6LGq6L-I5rCU5qaC77yb6ICM44CK57qi5qW85qKm44CL5YiZ5piv6YCa6L-H5a-56LS-5a6d546J5Y-K5YW25ZGo5Zu05Lq654mp5ZG96L-Q55qE5rex5YWl5YmW5p6Q77yM5Y-N5pig5LqG5bCB5bu656S-5Lya5pyr5pyf5aSn5a625peP55qE6I2j5p6v5YW06KGw5ZKM56S-5Lya546w5a6e55qE5rex5Yi75o-t56S644CC6L-Z5Zub5aSn5ZCN6JGX77yM5ZCE5YW354m56Imy77yM5ZCE5pyJ5Y2D56eL77yM5LiN5LuF5Zyo5Lit5Zu95paH5a2m5Y-y5LiK55WZ5LiL5LqG5rWT5aKo6YeN5b2p55qE5LiA56yU77yM5pu05Zyo5LiW55WM5paH5a2m6aKG5Z-f5YaF5Lqn55Sf5LqG5rex6L-c5b2x5ZON77yM5oiQ5Li65LqG5Lit5Y2O5paH5YyW5LiN5Y-v5oiW57y655qE6YeN6KaB57uE5oiQ6YOo5YiG44CCSample response
HTTP/1.1 200 OK
Server: AliyunOSS
Date: Thu, 10 Aug 2023 11:09:00 GMT
Content-Type: application/json;charset=UTF-8
Connection: close
Vary: Accept-Encoding
x-oss-request-id: 676144309D4E643133E487D4
x-oss-server-time: 2010
Content-Encoding: gzip
{
"RequestId":"676144309D4E643133E487D4",
"Output":{
"Text":"\"The Old Man and the Sea\" by Ernest Hemingway is a narrative about an elderly fisherman, Santiago, who embarks on an epic journey to catch a massive marlin. The story delves into themes of human endurance, perseverance, and the struggle against nature. Santiago's steadfast resolve and dignity amidst challenges highlight the resilience of the human spirit.",
"FinishReason":"stop"
}
}Summarize documents in SSE mode
Processing method
Document to be processed: example.doc
Text to be summarized: Ernest Hemingway's "The Old Man and the Sea" is a tale of an old fisherman, Santiago, and his epic struggle to catch a giant marlin. This story is a profound exploration of human endurance, perseverance, and the battle against the forces of nature. Santiago's unwavering determination and dignity in the face of adversity serve as a testament to the strength of the human spirit.
Response format: event-stream
Sample request
POST /example.doc?x-oss-process HTTP/1.1
Host: doc-demo.oss-cn-hangzhou.aliyuncs.com
Date: Fri, 28 Oct 2022 06:40:10 GMT
Authorization: OSS4-HMAC-SHA256 Credential=LTAI********************/20250417/cn-hangzhou/oss/aliyun_v4_request,Signature=a7c3554c729d71929e0b84489addee6b2e8d5cb48595adfc51868c299c0c218e
x-oss-process=doc/summarize,format_event-stream,content__5Zub5aSn5ZCN6JGX77yM6KKr6KqJ5Li65Lit5Zu95paH5a2m5a6d5bqT5Lit55qE55KA55Ko5piO54-g77yM5piv5Lit5Zu95Y-k5Luj5bCP6K-06Im65pyv5beF5bOw55qE6LGh5b6B44CC6L-Z5Zub6YOo5Li-5LiW6Ze75ZCN55qE5bCP6K-05beo6JGX77yM5YiG5Yir5piv572X6LSv5Lit5omA5Yib5L2c55qE5Y6G5Y-y6aKY5p2Q5bCP6K-044CK5LiJ5Zu95ryU5LmJ44CL77yM5ZC05om_5oGp56yU5LiL55qE56We6a2U5aWH5bm75L2c5ZOB44CK6KW_5ri46K6w44CL77yM5pa96ICQ5bq15Yib5L2c55qE6Iux6ZuE5Lyg5aWH5bCP6K-044CK5rC05rWS5Lyg44CL77yM5Lul5Y-K5pu56Zuq6Iq55pKw5YaZ55qE5Lq65oOF5LiW5pWF5LiO5a625peP5YW06KGw55qE57uP5YW45LmL5L2c44CK57qi5qW85qKm44CL44CC44CK5LiJ5Zu95ryU5LmJ44CL5Lul5Lic5rGJ5pyr5bm05Y-K5LiJ5Zu95pe25Luj5Li66IOM5pmv77yM55Sf5Yqo5o-P57uY5LqG576k6ZuE5LqJ6Zy455qE5Y6G5Y-y55S75Y2377yb44CK6KW_5ri46K6w44CL5YiZ5Lul5ZSQ5YOn5biI5b6S5Y-W57uP55qE5pWF5LqL5Li65Li757q_77yM6J6N5ZCI5LqG5aSn6YeP55qE56We6K-d5Lyg6K-05ZKM5rCR6Ze05pWF5LqL77yM5bGV546w5Ye65LiA5bmF55Gw5Li95aWH54m555qE56We6a2U5LiW55WM77yb44CK5rC05rWS5Lyg44CL6K6y6L-w5LqG5YyX5a6L5pyr5bm05qKB5bGx5aW95rGJ5Lus5Y-N5oqX5bCB5bu657uf5rK76ICF55qE5aOu5Li95Y-y6K-X77yM5bGV546w5LqG6I2J6I696Iux6ZuE5Lus55qE6LGq6L-I5rCU5qaC77yb6ICM44CK57qi5qW85qKm44CL5YiZ5piv6YCa6L-H5a-56LS-5a6d546J5Y-K5YW25ZGo5Zu05Lq654mp5ZG96L-Q55qE5rex5YWl5YmW5p6Q77yM5Y-N5pig5LqG5bCB5bu656S-5Lya5pyr5pyf5aSn5a625peP55qE6I2j5p6v5YW06KGw5ZKM56S-5Lya546w5a6e55qE5rex5Yi75o-t56S644CC6L-Z5Zub5aSn5ZCN6JGX77yM5ZCE5YW354m56Imy77yM5ZCE5pyJ5Y2D56eL77yM5LiN5LuF5Zyo5Lit5Zu95paH5a2m5Y-y5LiK55WZ5LiL5LqG5rWT5aKo6YeN5b2p55qE5LiA56yU77yM5pu05Zyo5LiW55WM5paH5a2m6aKG5Z-f5YaF5Lqn55Sf5LqG5rex6L-c5b2x5ZON77yM5oiQ5Li65LqG5Lit5Y2O5paH5YyW5LiN5Y-v5oiW57y655qE6YeN6KaB57uE5oiQ6YOo5YiG44CCSample response
HTTP/1.1 200 OK
Server: AliyunOSS
Date: Thu, 10 Aug 2023 11:20:11 GMT
Content-Type: text/event-stream;charset=UTF-8
Transfer-Encoding: chunked
Connection: close
x-oss-request-id: 669F7CE338492236349AF037
x-oss-server-time: 587
id: 0
event: Result
data: {"RequestId":"669F7CE338492236349AF037","Output":{"Text":"\"The","FinishReason":"null"}}
id: 1
event: Result
data: {"RequestId":"669F7CE338492236349AF037","Output":{"Text":"\"The Old","FinishReason":"null"}}
id: 2
event: Result
data: {"RequestId":"669F7CE338492236349AF037","Output":{"Text":"\"The Old Man","FinishReason":"null"}}
id: 3
event: Result
data: {"RequestId":"669F7CE338492236349AF037","Output":{"Text":"\"The Old Man and","FinishReason":"null"}}
id: 4
event: Result
data: {"RequestId":"669F7CE338492236349AF037","Output":{"Text":"\"The Old Man and the Sea\" by","FinishReason":"null"}}
id: 5
event: Result
data: {"RequestId":"669F7CE338492236349AF037","Output":{"Text":"\"The Old Man and the Sea\" by Ernest Hemingway","FinishReason":"null"}}
id: 6
event: Result
data: {"RequestId":"669F7CE338492236349AF037","Output":{"Text":"\"The Old Man and the Sea\" by Ernest Hemingway narrates the story","FinishReason":"null"}}
id: 7
event: Result
data: {"RequestId":"669F7CE338492236349AF037","Output":{"Text":"\"The Old Man and the Sea\" by Ernest Hemingway narrates the story of Santiago, an","FinishReason":"null"}}
id: 8
event: Result
data: {"RequestId":"669F7CE338492236349AF037","Output":{"Text":"\"The Old Man and the Sea\" by Ernest Hemingway narrates the story of Santiago, an elderly fisherman,","FinishReason":"null"}}
id: 9
event: Result
data: {"RequestId":"669F7CE338492236349AF037","Output":{"Text":"\"The Old Man and the Sea\" by Ernest Hemingway narrates the story of Santiago, an elderly fisherman, and his ardu","FinishReason":"null"}}
id: 10
event: Result
data: {"RequestId":"669F7CE338492236349AF037","Output":{"Text":"\"The Old Man and the Sea\" by Ernest Hemingway narrates the story of Santiago, an elderly fisherman, and his arduous journey to catch","FinishReason":"null"}}
id: 11
event: Result
data: {"RequestId":"669F7CE338492236349AF037","Output":{"Text":"\"The Old Man and the Sea\" by Ernest Hemingway narrates the story of Santiago, an elderly fisherman, and his arduous journey to catch a massive marlin","FinishReason":"null"}}
id: 12
event: Result
data: {"RequestId":"669F7CE338492236349AF037","Output":{"Text":"\"The Old Man and the Sea\" by Ernest Hemingway narrates the story of Santiago, an elderly fisherman, and his arduous journey to catch a massive marlin. The narrative del","FinishReason":"null"}}
id: 13
event: Result
data: {"RequestId":"669F7CE338492236349AF037","Output":{"Text":"\"The Old Man and the Sea\" by Ernest Hemingway narrates the story of Santiago, an elderly fisherman, and his arduous journey to catch a massive marlin. The narrative delves into themes of","FinishReason":"null"}}
id: 14
event: Result
data: {"RequestId":"669F7CE338492236349AF037","Output":{"Text":"\"The Old Man and the Sea\" by Ernest Hemingway narrates the story of Santiago, an elderly fisherman, and his arduous journey to catch a massive marlin. The narrative delves into themes of human endurance, perseverance","FinishReason":"null"}}
id: 15
event: Result
data: {"RequestId":"669F7CE338492236349AF037","Output":{"Text":"\"The Old Man and the Sea\" by Ernest Hemingway narrates the story of Santiago, an elderly fisherman, and his arduous journey to catch a massive marlin. The narrative delves into themes of human endurance, perseverance, and the struggle","FinishReason":"null"}}
id: 16
event: Result
data: {"RequestId":"669F7CE338492236349AF037","Output":{"Text":"\"The Old Man and the Sea\" by Ernest Hemingway narrates the story of Santiago, an elderly fisherman, and his arduous journey to catch a massive marlin. The narrative delves into themes of human endurance, perseverance, and the struggle against nature. Santiago","FinishReason":"null"}}
id: 17
event: Result
data: {"RequestId":"669F7CE338492236349AF037","Output":{"Text":"\"The Old Man and the Sea\" by Ernest Hemingway narrates the story of Santiago, an elderly fisherman, and his arduous journey to catch a massive marlin. The narrative delves into themes of human endurance, perseverance, and the struggle against nature. Santiago's steadfast resolve and","FinishReason":"null"}}
id: 18
event: Result
data: {"RequestId":"669F7CE338492236349AF037","Output":{"Text":"\"The Old Man and the Sea\" by Ernest Hemingway narrates the story of Santiago, an elderly fisherman, and his arduous journey to catch a massive marlin. The narrative delves into themes of human endurance, perseverance, and the struggle against nature. Santiago's steadfast resolve and dignity amidst challenges highlight","FinishReason":"null"}}
id: 19
event: Result
data: {"RequestId":"669F7CE338492236349AF037","Output":{"Text":"\"The Old Man and the Sea\" by Ernest Hemingway narrates the story of Santiago, an elderly fisherman, and his arduous journey to catch a massive marlin. The narrative delves into themes of human endurance, perseverance, and the struggle against nature. Santiago's steadfast resolve and dignity amidst challenges highlight the resilience of the","FinishReason":"null"}}
id: 20
event: Result
data: {"RequestId":"669F7CE338492236349AF037","Output":{"Text":"\"The Old Man and the Sea\" by Ernest Hemingway narrates the story of Santiago, an elderly fisherman, and his arduous journey to catch a massive marlin. The narrative delves into themes of human endurance, perseverance, and the struggle against nature. Santiago's steadfast resolve and dignity amidst challenges highlight the resilience of the human spirit.","FinishReason":"stop"}}Use OSS SDKs
The following sample code provides examples on how to summarize a document by using Object Storage Service (OSS) SDKs for common programming languages. If you want to summarize documents by using OSS SDKs for other programming languages, modify the parameters based on the following sample code.
Java
OSS SDK for Java V3.17.4 or later is required.
import com.aliyun.oss.*;
import com.aliyun.oss.common.auth.*;
import com.aliyun.oss.common.comm.SignVersion;
import com.aliyun.oss.common.utils.BinaryUtil;
import com.aliyun.oss.common.utils.IOUtils;
import com.aliyun.oss.model.GenericResult;
import com.aliyun.oss.model.ProcessObjectRequest;
import java.io.IOException;
import java.util.Formatter;
public class Demo {
public static void main(String[] args) throws ClientException, com.aliyuncs.exceptions.ClientException {
// Specify the endpoint of the region in which the bucket is located.
String endpoint = "http://oss-cn-hangzhou.aliyuncs.com";
// Specify the ID of the Alibaba Cloud region in which the bucket is located. Example: cn-hangzhou.
String region = "cn-hangzhou";
// Obtain access credentials from environment variables. Before you run the sample code, make sure that the OSS_ACCESS_KEY_ID and OSS_ACCESS_KEY_SECRET environment variables are configured.
EnvironmentVariableCredentialsProvider credentialsProvider = CredentialsProviderFactory.newEnvironmentVariableCredentialsProvider();
// Specify the name of the bucket.
String bucketName = "examplebucket";
// Specify the name of the document object, which is used only as a placeholder. Intelligent document summarization does not read the content of the document.
String key ="example.docx";
// Specify the text content to be summarized.
String content = "yourContent";
String encodeContent = BinaryUtil.toBase64String(content.getBytes()).replaceAll("\\+","-")
.replaceAll("/","_").replaceAll("=","");
// Create an OSSClient instance.
// Call the shutdown method to release resources when the OSSClient is no longer in use.
ClientBuilderConfiguration clientBuilderConfiguration = new ClientBuilderConfiguration();
clientBuilderConfiguration.setSignatureVersion(SignVersion.V4);
OSS ossClient = OSSClientBuilder.create()
.endpoint(endpoint)
.credentialsProvider(credentialsProvider)
.clientConfiguration(clientBuilderConfiguration)
.region(region)
.build();
try {
StringBuilder sbStyle = new StringBuilder();
Formatter styleFormatter = new Formatter(sbStyle);
// Create a processing instruction for intelligent document summarization.
styleFormatter.format("doc/summarize,content_%s",
encodeContent);
System.out.println(sbStyle.toString());
ProcessObjectRequest request = new ProcessObjectRequest(bucketName, key, sbStyle.toString());
GenericResult processResult = ossClient.processObject(request);
String json = IOUtils.readStreamAsString(processResult.getResponse().getContent(), "UTF-8");
processResult.getResponse().getContent().close();
System.out.println(json);
} catch (OSSException oe) {
System.out.println("Caught an OSSException, which means your request made it to OSS, "
+ "but was rejected with an error response for some reason.");
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("Caught an ClientException, which means the client encountered "
+ "a serious internal problem while trying to communicate with OSS, "
+ "such as not being able to access the network.");
System.out.println("Error Message:" + ce.getMessage());
} catch (IOException e) {
e.printStackTrace();
} finally {
if (ossClient != null) {
ossClient.shutdown();
}
}
}
}
PHP
OSS SDK for PHP V2.7.0 or later is required.
<?php
// Obtain access credentials from environment variables. Before you run the sample code, make sure that the OSS_ACCESS_KEY_ID and OSS_ACCESS_KEY_SECRET environment variables are configured.
$ak = getenv('OSS_ACCESS_KEY_ID');
$sk = getenv('OSS_ACCESS_KEY_SECRET');
// Specify the name of the bucket. Example: examplebucket.
$bucket = 'examplebucket';
// Specify the name of the document object, which is used only as a placeholder. Intelligent document summarization does not read the content of the document.
$objectKey = 'example.docx';
// Specify the text content to be summarized.
$txt = "yourTxt";
$base64url = str_replace(['+', '/', '='], ['-', '_', ''], base64_encode($txt));
// Create a processing instruction for intelligent document summarization.
$body = sprintf("x-oss-process=doc/summarize,content_%s", $base64url);
$httpVerb = 'POST';
$contentMd5 = base64_encode(md5($body, true));
$contentType = '';
$date = gmdate('D, d M Y H:i:s T');
$stringToSign = $httpVerb . "\n" . $contentMd5 . "\n" . $contentType . "\n" . $date . "\n" . "/{$bucket}/{$objectKey}?x-oss-process";
$signature = base64_encode(hash_hmac('sha1', $stringToSign, $sk, true));
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://{$bucket}.oss-cn-hangzhou.aliyuncs.com/{$objectKey}?x-oss-process");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Date: ' . $date,
'Authorization: OSS ' . $ak . ':' . $signature,
'Content-Type: ' . $contentType,
'Content-Md5:' . $contentMd5,
));
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
$response = curl_exec($ch);
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($response === false) {
echo "Error: " . curl_error($ch);
} else {
if ($httpcode == 200) {
var_dump($response);
} else {
echo "Error: HTTP code " . $httpcode;
}
}Go
OSS SDK for Go V3.0.2 or later is required.
package main
import (
"encoding/base64"
"encoding/json"
"fmt"
"io"
"os"
"strings"
"github.com/aliyun/aliyun-oss-go-sdk/oss"
)
type TextData struct {
RequestId string `json:"RequestId"`
Output struct {
Text string `json:"Text"`
FinishReason string `json:"FinishReason"`
} `json:"Output"`
}
func main() {
// Obtain the temporary access credentials from the environment variables. Before you run the sample code, make sure that the OSS_ACCESS_KEY_ID, OSS_ACCESS_KEY_SECRET, and OSS_SESSION_TOKEN environment variables are configured.
provider, err := oss.NewEnvironmentVariableCredentialsProvider()
if err != nil {
fmt.Println("Error:", err)
os.Exit(-1)
}
// Create an OSSClient instance.
client, err := oss.New("https://oss-cn-hangzhou.aliyuncs.com", "", "", oss.SetCredentialsProvider(&provider), oss.AuthVersion(oss.AuthV4), oss.Region("cn-hangzhou"))
if err != nil {
fmt.Println("Error:", err)
os.Exit(-1)
}
// Specify the name of the bucket. Example: examplebucket.
bucketName := "examplebucket"
bucket, err := client.Bucket(bucketName)
if err != nil {
fmt.Println("Error:", err)
os.Exit(-1)
}
params := make(map[string]interface{})
params["x-oss-process"] = nil
// Specify the text content to be summarized.
txt := "yourTxt"
// Create a processing instruction for intelligent document summarization.
data := fmt.Sprintf("x-oss-process=doc/summarize,content_%v", base64.URLEncoding.EncodeToString([]byte(txt)))
// example.docx is a document in the bucket. It is used as a placeholder. Intelligent document summarization does not read the content of the document.
response, err := bucket.Do("POST", "example.docx", params, nil, strings.NewReader(data), nil)
if err != nil {
fmt.Println("Error:", err)
os.Exit(-1)
}
defer response.Body.Close()
jsonData, err := io.ReadAll(response.Body)
if err != nil {
fmt.Println("Error:", err)
os.Exit(-1)
}
var text TextData
err = json.Unmarshal(jsonData, &text)
if err != nil {
fmt.Println("Error:", err)
os.Exit(-1)
}
fmt.Printf("RequestId:%v\n", text.RequestId)
fmt.Printf("Text:%v\n", text.Output.Text)
fmt.Printf("FinishReason:%v\n", text.Output.FinishReason)
}