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

@@ -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);
}