mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-16 13:27:08 +00:00
fix: 修复和优化群聊文件读取逻辑
This commit is contained in:
parent
d254163fa7
commit
e61d4ff3fa
3 changed files with 17 additions and 6 deletions
|
|
@ -14,6 +14,7 @@ import { translate } from './translate.js'
|
|||
import uploadRecord from './uploadRecord.js'
|
||||
import Version from './version.js'
|
||||
import fetch, { FormData, fileFromSync } from 'node-fetch'
|
||||
import https from "https";
|
||||
let pdfjsLib
|
||||
try {
|
||||
pdfjsLib = (await import('pdfjs-dist')).default
|
||||
|
|
@ -1034,10 +1035,15 @@ export function getUserSpeaker (userSetting) {
|
|||
* @param url 要下载的文件链接
|
||||
* @param destPath 目标路径,如received/abc.pdf. 目前如果文件名重复会覆盖。
|
||||
* @param absolute 是否是绝对路径,默认为false,此时拼接在data/chatgpt下
|
||||
* @param ignoreCertificateError 忽略证书错误
|
||||
* @returns {Promise<string>} 最终下载文件的存储位置
|
||||
*/
|
||||
export async function downloadFile (url, destPath, absolute = false) {
|
||||
let response = await fetch(url)
|
||||
export async function downloadFile (url, destPath, absolute = false, ignoreCertificateError = true) {
|
||||
let response = await fetch(url, {
|
||||
agent: new https.Agent({
|
||||
rejectUnauthorized: !ignoreCertificateError
|
||||
})
|
||||
})
|
||||
if (!response.ok) {
|
||||
throw new Error(`download file http error: status: ${response.status}`)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue