spring-ai
spring-ai copied to clipboard
Support URI in Media
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"));