mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Fix fetch buffer deprecation warnings
This commit is contained in:
@@ -79,7 +79,7 @@ router.post('/generate', jsonParser, async (req, res) => {
|
|||||||
return res.sendStatus(500);
|
return res.sendStatus(500);
|
||||||
}
|
}
|
||||||
|
|
||||||
const audio = await response.buffer();
|
const audio = Buffer.from(await response.arrayBuffer());
|
||||||
res.set('Content-Type', 'audio/ogg');
|
res.set('Content-Type', 'audio/ogg');
|
||||||
return res.send(audio);
|
return res.send(audio);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
@@ -336,7 +336,7 @@ async function downloadChubLorebook(id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const name = id.split('/').pop();
|
const name = id.split('/').pop();
|
||||||
const buffer = await result.buffer();
|
const buffer = Buffer.from(await result.arrayBuffer());
|
||||||
const fileName = `${sanitize(name)}.json`;
|
const fileName = `${sanitize(name)}.json`;
|
||||||
const fileType = result.headers.get('content-type');
|
const fileType = result.headers.get('content-type');
|
||||||
|
|
||||||
@@ -359,7 +359,7 @@ async function downloadChubCharacter(id) {
|
|||||||
throw new Error('Failed to download character');
|
throw new Error('Failed to download character');
|
||||||
}
|
}
|
||||||
|
|
||||||
const buffer = await result.buffer();
|
const buffer = Buffer.from(await result.arrayBuffer());
|
||||||
const fileName = result.headers.get('content-disposition')?.split('filename=')[1] || `${sanitize(id)}.png`;
|
const fileName = result.headers.get('content-disposition')?.split('filename=')[1] || `${sanitize(id)}.png`;
|
||||||
const fileType = result.headers.get('content-type');
|
const fileType = result.headers.get('content-type');
|
||||||
|
|
||||||
@@ -398,7 +398,7 @@ async function downloadPygmalionCharacter(id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const avatarResult = await fetch(avatarUrl);
|
const avatarResult = await fetch(avatarUrl);
|
||||||
const avatarBuffer = await avatarResult.buffer();
|
const avatarBuffer = Buffer.from(await avatarResult.arrayBuffer());
|
||||||
|
|
||||||
const cardBuffer = write(avatarBuffer, JSON.stringify(characterData));
|
const cardBuffer = write(avatarBuffer, JSON.stringify(characterData));
|
||||||
|
|
||||||
@@ -477,7 +477,7 @@ async function downloadJannyCharacter(uuid) {
|
|||||||
const downloadResult = await result.json();
|
const downloadResult = await result.json();
|
||||||
if (downloadResult.status === 'ok') {
|
if (downloadResult.status === 'ok') {
|
||||||
const imageResult = await fetch(downloadResult.downloadUrl);
|
const imageResult = await fetch(downloadResult.downloadUrl);
|
||||||
const buffer = await imageResult.buffer();
|
const buffer = Buffer.from(await imageResult.arrayBuffer());
|
||||||
const fileName = `${sanitize(uuid)}.png`;
|
const fileName = `${sanitize(uuid)}.png`;
|
||||||
const fileType = imageResult.headers.get('content-type');
|
const fileType = imageResult.headers.get('content-type');
|
||||||
|
|
||||||
@@ -499,7 +499,7 @@ async function downloadAICCCharacter(id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const contentType = response.headers.get('content-type') || 'image/png'; // Default to 'image/png' if header is missing
|
const contentType = response.headers.get('content-type') || 'image/png'; // Default to 'image/png' if header is missing
|
||||||
const buffer = await response.buffer();
|
const buffer = Buffer.from(await response.arrayBuffer());
|
||||||
const fileName = `${sanitize(id)}.png`; // Assuming PNG, but adjust based on actual content or headers
|
const fileName = `${sanitize(id)}.png`; // Assuming PNG, but adjust based on actual content or headers
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -537,7 +537,7 @@ async function downloadGenericPng(url) {
|
|||||||
const result = await fetch(url);
|
const result = await fetch(url);
|
||||||
|
|
||||||
if (result.ok) {
|
if (result.ok) {
|
||||||
const buffer = await result.buffer();
|
const buffer = Buffer.from(await result.arrayBuffer());
|
||||||
const fileName = sanitize(result.url.split('?')[0].split('/').reverse()[0]);
|
const fileName = sanitize(result.url.split('?')[0].split('/').reverse()[0]);
|
||||||
const contentType = result.headers.get('content-type') || 'image/png'; //yoink it from AICC function lol
|
const contentType = result.headers.get('content-type') || 'image/png'; //yoink it from AICC function lol
|
||||||
|
|
||||||
@@ -581,7 +581,7 @@ async function downloadRisuCharacter(uuid) {
|
|||||||
throw new Error('Failed to download character');
|
throw new Error('Failed to download character');
|
||||||
}
|
}
|
||||||
|
|
||||||
const buffer = await result.buffer();
|
const buffer = Buffer.from(await result.arrayBuffer());
|
||||||
const fileName = `${sanitize(uuid)}.png`;
|
const fileName = `${sanitize(uuid)}.png`;
|
||||||
const fileType = 'image/png';
|
const fileType = 'image/png';
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user