Skip to content

Commit

Permalink
Support File URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
lahirumaramba committed May 9, 2024
1 parent 6227ee7 commit 74b53e8
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/main/src/files/file-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,11 @@ export class GoogleAIFileManager {
filePath: string,
fileMetadata: FileMetadata,
): Promise<UploadFileResponse> {
const file = readFileSync(filePath);
var filePathOrUrl: URL | string = filePath;
if (filePath.startsWith("file://")) {
filePathOrUrl = new URL(filePath);
}
const file = readFileSync(filePathOrUrl);
const url = new FilesRequestUrl(
FilesTask.UPLOAD,
this.apiKey,
Expand Down

0 comments on commit 74b53e8

Please sign in to comment.