Skip to content

Support URI in Media #1147

@dmelikhov

Description

@dmelikhov

Context
I can't attach GCS files when using Gemini:

new Media(MediaType.IMAGE_JPEG, new URL("https://storage.googleapis.com/my-bucket/my-image.jpeg"));
// io.grpc.StatusRuntimeException: INVALID_ARGUMENT: Only GCS URIs are supported in file_uri and please make sure that the path is a valid GCS path.

new Media(MediaType.IMAGE_JPEG, new URL("gs://my-bucket/my-image.jpeg"));
// java.net.MalformedURLException: unknown protocol: gs

new Media(MediaType.IMAGE_JPEG, "gs://my-bucket/my-image.jpeg"));
// works, but this constructor is deprecated and marked for removal 

Expected Behavior
A constructor with URI parameter would solve the issue:

new Media(MediaType.IMAGE_JPEG, URI.create("gs://my-bucket/my-image.jpeg"));

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions