diff --git a/front/pages/api/w/[wId]/assistant/agent_configurations/avatar.ts b/front/pages/api/w/[wId]/assistant/agent_configurations/avatar.ts index e892a3a82885..3392ce138f09 100644 --- a/front/pages/api/w/[wId]/assistant/agent_configurations/avatar.ts +++ b/front/pages/api/w/[wId]/assistant/agent_configurations/avatar.ts @@ -1,11 +1,10 @@ -import { Storage } from "@google-cloud/storage"; import { IncomingForm } from "formidable"; import type { NextApiRequest, NextApiResponse } from "next"; import { uploadToBucket } from "@app/lib/dfs"; import { withLogging } from "@app/logger/withlogging"; -const { DUST_UPLOAD_BUCKET = "", SERVICE_ACCOUNT } = process.env; +const { DUST_UPLOAD_BUCKET = "" } = process.env; export const config = { api: { @@ -13,31 +12,6 @@ export const config = { }, }; -export async function assertIsSelfHostedPictureUrl(pictureUrl: string) { - const isSelfHosted = pictureUrl.startsWith( - `https://storage.googleapis.com/${DUST_UPLOAD_BUCKET}/` - ); - - const storage = new Storage({ - keyFilename: SERVICE_ACCOUNT, - }); - - const filename = pictureUrl.split("/").at(-1); - if (!filename) { - return false; - } - - const bucket = storage.bucket(DUST_UPLOAD_BUCKET); - const gcsFile = await bucket.file(filename); - - const [metadata] = await gcsFile.getMetadata(); - - const isImageContentType = - metadata.contentType && metadata.contentType.includes("image"); - - return isSelfHosted && isImageContentType; -} - async function handler( req: NextApiRequest, res: NextApiResponse