Fix fetch buffer deprecation warnings

5db7a9cf1e72ee35ecc331454dc06937a9762075

Cohee <18619528+Cohee1207@users.noreply.github.com>

2 files changed, +8 -8Showing whitespace changes
src/endpoints/azure.js+1 -1
@@ -79,7 +79,7 @@ router.post('/generate', jsonParser, async (req, res) => {
79 return res.sendStatus(500);79 return res.sendStatus(500);
80 }80 }
8181
82 const audio = await response.buffer();82 const audio = Buffer.from(await response.arrayBuffer());
83 res.set('Content-Type', 'audio/ogg');83 res.set('Content-Type', 'audio/ogg');
84 return res.send(audio);84 return res.send(audio);
85 } catch (error) {85 } catch (error) {
src/endpoints/content-manager.js+7 -7
@@ -336,7 +336,7 @@ async function downloadChubLorebook(id) {
336 }336 }
337337
338 const name = id.split('/').pop();338 const name = id.split('/').pop();
339 const buffer = await result.buffer();339 const buffer = Buffer.from(await result.arrayBuffer());
340 const fileName = `${sanitize(name)}.json`;340 const fileName = `${sanitize(name)}.json`;
341 const fileType = result.headers.get('content-type');341 const fileType = result.headers.get('content-type');
342342
@@ -359,7 +359,7 @@ async function downloadChubCharacter(id) {
359 throw new Error('Failed to download character');359 throw new Error('Failed to download character');
360 }360 }
361361
362 const buffer = await result.buffer();362 const buffer = Buffer.from(await result.arrayBuffer());
363 const fileName = result.headers.get('content-disposition')?.split('filename=')[1] || `${sanitize(id)}.png`;363 const fileName = result.headers.get('content-disposition')?.split('filename=')[1] || `${sanitize(id)}.png`;
364 const fileType = result.headers.get('content-type');364 const fileType = result.headers.get('content-type');
365365
@@ -398,7 +398,7 @@ async function downloadPygmalionCharacter(id) {
398 }398 }
399399
400 const avatarResult = await fetch(avatarUrl);400 const avatarResult = await fetch(avatarUrl);
401 const avatarBuffer = await avatarResult.buffer();401 const avatarBuffer = Buffer.from(await avatarResult.arrayBuffer());
402402
403 const cardBuffer = write(avatarBuffer, JSON.stringify(characterData));403 const cardBuffer = write(avatarBuffer, JSON.stringify(characterData));
404404
@@ -477,7 +477,7 @@ async function downloadJannyCharacter(uuid) {
477 const downloadResult = await result.json();477 const downloadResult = await result.json();
478 if (downloadResult.status === 'ok') {478 if (downloadResult.status === 'ok') {
479 const imageResult = await fetch(downloadResult.downloadUrl);479 const imageResult = await fetch(downloadResult.downloadUrl);
480 const buffer = await imageResult.buffer();480 const buffer = Buffer.from(await imageResult.arrayBuffer());
481 const fileName = `${sanitize(uuid)}.png`;481 const fileName = `${sanitize(uuid)}.png`;
482 const fileType = imageResult.headers.get('content-type');482 const fileType = imageResult.headers.get('content-type');
483483
@@ -499,7 +499,7 @@ async function downloadAICCCharacter(id) {
499 }499 }
500500
501 const contentType = response.headers.get('content-type') || 'image/png'; // Default to 'image/png' if header is missing501 const contentType = response.headers.get('content-type') || 'image/png'; // Default to 'image/png' if header is missing
502 const buffer = await response.buffer();502 const buffer = Buffer.from(await response.arrayBuffer());
503 const fileName = `${sanitize(id)}.png`; // Assuming PNG, but adjust based on actual content or headers503 const fileName = `${sanitize(id)}.png`; // Assuming PNG, but adjust based on actual content or headers
504504
505 return {505 return {
@@ -537,7 +537,7 @@ async function downloadGenericPng(url) {
537 const result = await fetch(url);537 const result = await fetch(url);
538538
539 if (result.ok) {539 if (result.ok) {
540 const buffer = await result.buffer();540 const buffer = Buffer.from(await result.arrayBuffer());
541 const fileName = sanitize(result.url.split('?')[0].split('/').reverse()[0]);541 const fileName = sanitize(result.url.split('?')[0].split('/').reverse()[0]);
542 const contentType = result.headers.get('content-type') || 'image/png'; //yoink it from AICC function lol542 const contentType = result.headers.get('content-type') || 'image/png'; //yoink it from AICC function lol
543543
@@ -581,7 +581,7 @@ async function downloadRisuCharacter(uuid) {
581 throw new Error('Failed to download character');581 throw new Error('Failed to download character');
582 }582 }
583583
584 const buffer = await result.buffer();584 const buffer = Buffer.from(await result.arrayBuffer());
585 const fileName = `${sanitize(uuid)}.png`;585 const fileName = `${sanitize(uuid)}.png`;
586 const fileType = 'image/png';586 const fileType = 'image/png';
587587