fix(FileStorage): update base64File method to return base64 string instead of Buffer
This commit is contained in:
@@ -274,9 +274,10 @@ class FileStorage {
|
||||
public base64File = async (
|
||||
_: Electron.IpcMainInvokeEvent,
|
||||
filePath: string
|
||||
): Promise<{ data: Buffer; mime: string }> => {
|
||||
): Promise<{ data: string; mime: string }> => {
|
||||
const fileBuffer = await fs.promises.readFile(filePath)
|
||||
return {
|
||||
data: await fs.promises.readFile(filePath),
|
||||
data: fileBuffer.toString('base64'),
|
||||
mime: 'application/pdf'
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -74,7 +74,7 @@ declare global {
|
||||
) => Promise<string | null>
|
||||
saveImage: (name: string, data: string) => void
|
||||
base64Image: (fileId: string) => Promise<{ mime: string; base64: string; data: string }>
|
||||
base64File: (filePath: string) => Promise<{ mime: string; data: Buffer }>
|
||||
base64File: (filePath: string) => Promise<{ mime: string; data: string }>
|
||||
download: (url: string) => Promise<FileType | null>
|
||||
copy: (fileId: string, destPath: string) => Promise<void>
|
||||
binaryFile: (fileId: string) => Promise<{ data: Buffer; mime: string }>
|
||||
|
||||
@@ -88,7 +88,7 @@ export default class GeminiProvider extends BaseProvider {
|
||||
const { data, mimeType } = await fileToBase64(file.path)
|
||||
return {
|
||||
inlineData: {
|
||||
data: data.toString('base64'),
|
||||
data: data,
|
||||
mimeType
|
||||
}
|
||||
} as InlineDataPart
|
||||
@@ -150,7 +150,6 @@ export default class GeminiProvider extends BaseProvider {
|
||||
}
|
||||
|
||||
for (const file of message.files || []) {
|
||||
console.log('file', file)
|
||||
if (file.type === FileTypes.IMAGE) {
|
||||
const base64Data = await window.api.file.base64Image(file.id + file.ext)
|
||||
parts.push({
|
||||
|
||||
Reference in New Issue
Block a user