public static Part fromMimeTypeAndData(String mimeType, Object partData) {
    Part part;
    if (partData instanceof byte[]) {
      byte[] bytes = (byte[]) partData;
      ByteString byteData = ByteString.copyFrom(bytes);
      part =
          Part.newBuilder()
              .setInlineData(Blob.newBuilder().setMimeType(mimeType).setData(byteData))
              .build();
    } else if (partData instanceof String) {
      String uri = (String) partData;
      part =
          Part.newBuilder()
              .setFileData(FileData.newBuilder().setMimeType(mimeType).setFileUri(uri))
              .build();
    } else if (partData instanceof URI) {
      URI uri = (URI) partData;
      part =
          Part.newBuilder()
              .setFileData(FileData.newBuilder().setMimeType(mimeType).setFileUri(uri.toString()))
              .build();
    } else if (partData instanceof ByteString) {
      ByteString byteData = (ByteString) partData;
      part =
          Part.newBuilder()
              .setInlineData(Blob.newBuilder().setMimeType(mimeType).setData(byteData))
              .build();
    } else {
      throw new IllegalArgumentException(
          "The second element of the input List can only be one of the following format:"
              + " byte[], String, URI, ByteString");
    }
    return part;
  }
Makes a {@link com.google.cloud.vertexai.api.Part} from mimeType and data (or link to the
data).

@param mimeType currently accepted values are "image/png", "image/jpeg", "video/mp4",
    "video/mpeg", "video/quicktime", "video/x-msvideo", "video/x-ms-wmv", "video/x-flv"
@param partData the following types can be accepted.
    <ul>
      <li>a String representing the uri of the data. Resulting Part will have fileData field
          set.
      <li>a GCS URI object. Resulting Part will have fileData field set.
      <li>byte arrays that represents the actual data. Resulting Part will have inlineData
          field set.
      <li>com.google.protobuf.ByteString that represents the actual data. Resulting Part will
          have inlineData field set.
    </ul>
java-vertexai/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/generativeai/PartMaker.java