We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent f303041 commit f436d58Copy full SHA for f436d58
src/utils/file.ts
@@ -360,8 +360,13 @@ async function mpFileUpload(file: File) {
360
}
361
362
let url = `https://api.weixin.qq.com/cgi-bin/material/add_material?access_token=${access_token}&type=image`
363
+ const fileSizeInMB = file.size / (1024 * 1024)
364
+ const fileType = file.type.toLowerCase()
365
+ if (fileSizeInMB < 1 && (fileType === `image/jpeg` || fileType === `image/png`)) {
366
+ url = `https://api.weixin.qq.com/cgi-bin/media/uploadimg?access_token=${access_token}`
367
+ }
368
if (proxyOrigin) {
- url = `${proxyOrigin}/cgi-bin/material/add_material?access_token=${access_token}&type=image`
369
+ url = url.replace(`https://api.weixin.qq.com`, proxyOrigin)
370
371
372
const res = await fetch<any, { url: string }>(url, requestOptions)
0 commit comments