forked from yoone/API
parent
4bde698625
commit
e30cce45b7
|
|
@ -1205,10 +1205,12 @@ public async fetchMediaPaged(site: any, params: Partial<WpMediaGetListParams> =
|
|||
throw new Error('source_url 不存在');
|
||||
}
|
||||
// 下载源文件为 Buffer
|
||||
const resp = await axios.get(srcUrl, { responseType: 'arraybuffer', timeout: 30000,
|
||||
const resp = await axios.get(srcUrl, {
|
||||
responseType: 'arraybuffer', timeout: 30000,
|
||||
headers: {
|
||||
'User-Agent': 'Mozilla/5.0 (compatible; Node.js Axios)',
|
||||
} });
|
||||
}
|
||||
});
|
||||
const inputBuffer = Buffer.from(resp.data);
|
||||
// 条件判断 如果下载的 Buffer 为空则抛出错误
|
||||
if (!inputBuffer || inputBuffer.length === 0) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue