fix(toBase64): remove image-to-base64 dependencies

This commit is contained in:
Hexagonn
2024-10-20 13:16:43 +00:00
committed by GitHub
parent be11864c21
commit c69691e7d5
4 changed files with 3499 additions and 5 deletions

View File

@@ -8,11 +8,10 @@
"start": "next start",
"lint": "next lint"
},
"packageManager": "pnpm@9.11.0",
"dependencies": {
"@types/escape-html": "^1.0.4",
"@types/image-to-base64": "^2.1.2",
"escape-html": "^1.0.3",
"image-to-base64": "^2.2.0",
"ioredis": "^5.4.1",
"next": "14.2.15",
"react": "^18",

3491
pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,3 +1,4 @@
"use server";
// probably the messiest code i've ever written but it works so :)
import { Badges } from "#/public/assets/badges/BadgesEncoded";

View File

@@ -1,10 +1,13 @@
import imageToBase64 from "image-to-base64";
export const encodeBase64 = async (url: string): Promise<string> => {
let response = "";
try {
response = await imageToBase64(url);
response = await fetch(url)
.then((res) => res.blob())
.then(async (blob) => {
const buffer = Buffer.from(await blob.arrayBuffer());
return buffer.toString("base64");
});
} catch (e) {
console.log(e);
}