Skip to content

Commit 5bb3b92

Browse files
committed
feat(playable-ads-adapter): 调整压缩图片读写文件逻辑
1 parent 298b724 commit 5bb3b92

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

packages/playable-ads-adapter/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "1.1.0",
2+
"version": "1.1.1",
33
"name": "playable-ads-adapter",
44
"main": "./main.js",
55
"devDependencies": {

packages/playable-ads-adapter/src/core/plugins/tinify/index.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { checkImgType, getAllFilesFormDir, getOriginPkgPath, getRCTinify, writeT
66
export const postFileToRemote = (filePath: string, data: Buffer): Promise<void> => {
77
const { tinifyApiKey } = getRCTinify()
88
return new Promise((resolve, reject) => {
9+
console.log('【准备上传图片到TinyPng】 ', filePath)
910
Axios.request({
1011
method: 'post',
1112
url: 'https://api.tinify.com/shrink',
@@ -15,12 +16,13 @@ export const postFileToRemote = (filePath: string, data: Buffer): Promise<void>
1516
},
1617
data
1718
}).then((response) => {
19+
console.log('【准备下载压缩图片】 ', filePath)
1820
Axios.request({
1921
method: 'get',
2022
url: response.data.output.url,
2123
responseType: 'arraybuffer'
2224
}).then((fileResponse) => {
23-
writeToPath(filePath, fileResponse.data)
25+
writeToPath(filePath, Buffer.from(fileResponse.data))
2426
console.log('【压缩图片完成】 ', filePath)
2527
resolve()
2628
}).catch((fileErr) => {

0 commit comments

Comments
 (0)