Ollama4j
A Java library (wrapper/binding) for Ollama server.
Loading...
Searching...
No Matches
FileToBase64Serializer.java
Go to the documentation of this file.
1package io.github.ollama4j.utils;
2
3import java.io.IOException;
4import java.util.Base64;
5import java.util.Collection;
6
7import com.fasterxml.jackson.core.JsonGenerator;
8import com.fasterxml.jackson.databind.JsonSerializer;
9import com.fasterxml.jackson.databind.SerializerProvider;
10
11public class FileToBase64Serializer extends JsonSerializer<Collection<byte[]>> {
12
13 @Override
14 public void serialize(Collection<byte[]> value, JsonGenerator jsonGenerator, SerializerProvider serializers) throws IOException {
15 jsonGenerator.writeStartArray();
16 for (byte[] file : value) {
17 jsonGenerator.writeString(Base64.getEncoder().encodeToString(file));
18 }
19 jsonGenerator.writeEndArray();
20 }
21}
void serialize(Collection< byte[]> value, JsonGenerator jsonGenerator, SerializerProvider serializers)