wx2tg-puppet 2.0.6 → 2.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -113,20 +113,24 @@ const say = (content, toWxid, ats) => __awaiter(void 0, void 0, void 0, function
113
113
  default:
114
114
  fileType = 'other';
115
115
  }
116
- const base64 = yield content.toBase64();
117
116
  switch (fileType) {
118
117
  case 'image':
119
118
  // console.log('上传图片', base64)
119
+ const base64 = yield content.toBase64();
120
120
  return MsgApi_1.msgApi.UploadImg({
121
121
  "Base64": base64,
122
122
  "ToWxid": toWxid,
123
123
  "Wxid": (config === null || config === void 0 ? void 0 : config.wxid) || ''
124
124
  });
125
125
  case 'other':
126
- const res = yield ToolsApi_1.toolsApi.UploadFile({
127
- "base64": base64,
128
- "wxid": config === null || config === void 0 ? void 0 : config.wxid
129
- });
126
+ // 直接从 FileBox 获取文件内容
127
+ const fileBuffer = yield content.toBuffer();
128
+ const fileBlob = new Blob([fileBuffer]);
129
+ // 创建 FormData
130
+ const formData = new FormData();
131
+ formData.append('wxid', (config === null || config === void 0 ? void 0 : config.wxid) || '');
132
+ formData.append('file', fileBlob, fileName);
133
+ const res = yield ToolsApi_1.toolsApi.UploadFileBinary(formData);
130
134
  const size = res.data.Data.totalLen;
131
135
  const mediaId = res.data.Data.mediaId;
132
136
  if (!config)
@@ -137,7 +141,7 @@ const say = (content, toWxid, ats) => __awaiter(void 0, void 0, void 0, function
137
141
  "Wxid": config === null || config === void 0 ? void 0 : config.wxid,
138
142
  "Xml": `<appmsg appid='wxeb7ec651dd0aefa9' sdkver=''><title>${fileName}</title><des></des><action></action><type>6</type><content></content><url></url><lowurl></lowurl><appattach><totallen>${size}</totallen><attachid>${mediaId}</attachid><fileext>${ext}</fileext></appattach><extinfo></extinfo></appmsg>`
139
143
  });
140
- return new Message_1.ResponseMsg(res1.data.Data.List[0]);
144
+ return new Message_1.ResponseMsg(res1.data.Data);
141
145
  }
142
146
  }
143
147
  // else if(content instanceof URLLINK){
@@ -33,6 +33,8 @@ declare class ToolsApi {
33
33
  UpdateStepNumberApi(body: any): Promise<AxiosResponse<ApiResponse>>;
34
34
  /** 文件上传 */
35
35
  UploadFile(body: any): Promise<AxiosResponse<ApiResponse>>;
36
+ /** 二进制文件上传 */
37
+ UploadFileBinary(formData: FormData): Promise<AxiosResponse<ApiResponse>>;
36
38
  /** 设置/删除代理IP */
37
39
  setproxy(body: any): Promise<AxiosResponse<ApiResponse>>;
38
40
  /** CDN图片下载 */
@@ -67,6 +67,14 @@ class ToolsApi {
67
67
  UploadFile(body) {
68
68
  return axiosInstance_1.axiosInstance.post('/Tools/UploadFile', body);
69
69
  }
70
+ /** 二进制文件上传 */
71
+ UploadFileBinary(formData) {
72
+ return axiosInstance_1.axiosInstance.post('/Tools/UploadFileBinary', formData, {
73
+ headers: {
74
+ 'Content-Type': 'multipart/form-data',
75
+ },
76
+ });
77
+ }
70
78
  /** 设置/删除代理IP */
71
79
  setproxy(body) {
72
80
  return axiosInstance_1.axiosInstance.post('/Tools/setproxy', body);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wx2tg-puppet",
3
- "version": "2.0.6",
3
+ "version": "2.0.7",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [