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"));

Comment From: ddobrin

Maybe you could test this approach extracted from a snippet: ... // bucket where image has been uploaded String imageURL = String.format("gs://%s/%s",bucketName, fileName);

    // create User Message for AI framework
    PromptTemplate userPromptTemplate = new PromptTemplate(imageUserMessage);
    Message imageAnalysisUserMessage = userPromptTemplate.createMessage(List.of(new 
                               Media(MimeTypeUtils.parseMimeType("image/*"), imageURL)));

...