mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-27 00:17:31 +00:00
@@ -9,3 +9,21 @@ export const removeFilesByPaths = (paths: string[]) => {
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
const imageTypeMap: Record<string, string> = {
|
||||
'/': 'image/jpeg',
|
||||
i: 'image/png',
|
||||
R: 'image/gif',
|
||||
U: 'image/webp',
|
||||
Q: 'image/bmp'
|
||||
};
|
||||
|
||||
export const guessImageTypeFromBase64 = (str: string) => {
|
||||
const defaultType = 'image/jpeg';
|
||||
if (typeof str !== 'string' || str.length === 0) {
|
||||
return defaultType;
|
||||
}
|
||||
|
||||
const firstChar = str.charAt(0);
|
||||
return imageTypeMap[firstChar] || defaultType;
|
||||
};
|
||||
|
Reference in New Issue
Block a user