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