Skip to content

Commit d6a29f2

Browse files
authored
Merge pull request #19 from zhxycn/master
fix: incorrect content format error
2 parents 9ac506b + 52a7a12 commit d6a29f2

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

packages/tencent-tms/index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,12 @@ module.exports = function({secretId, secretKey, region}) {
3131
}
3232

3333
const client = new TmsClient(clientConfig);
34+
35+
// encode comment as Base64 in UTF-8 format
36+
const encodedComment = Buffer.from(data.comment, 'utf8').toString('base64');
37+
3438
try {
35-
const resp = await client.TextModeration({ Content: data.comment });
39+
const resp = await client.TextModeration({ Content: encodedComment });
3640
if (!resp.Suggestion) {
3741
throw new Error('Suggestion is empty. Tencent Cloud TMS info:', resp);
3842
}

0 commit comments

Comments
 (0)