fix: base64 image (#3238)

* fix: base64 image

* perf: quote qa
This commit is contained in:
Archer
2024-11-26 13:28:51 +08:00
committed by GitHub
parent cf1a90c596
commit a75036b626
5 changed files with 51 additions and 34 deletions

View File

@@ -23,6 +23,11 @@ export const parseUrlToFileType = (url: string): UserChatItemValueItemType['file
const parseUrl = new URL(url, 'https://locaohost:3000');
const filename = (() => {
// Check base64 image
if (url.startsWith('data:image/')) {
const mime = url.split(',')[0].split(':')[1].split(';')[0];
return `image.${mime.split('/')[1]}`;
}
// Old version file url: https://xxx.com/file/read?filename=xxx.pdf
const filenameQuery = parseUrl.searchParams.get('filename');
if (filenameQuery) return filenameQuery;