Skip to content

[Feature]: Pass binary file contents (Images, PDFs) to AI service during batch upload ingestion (backend) #250

Description

@daniilperkin

User Story

As a user, I want to upload images and PDFs to the knowledge base, so that the AI can properly caption images and parse PDFs, providing accurate summaries of their contents.

Context & Motivation

Currently, binary files uploaded to the knowledge base fail to summarize because:

UploadArtifactMapper doesn't map their MIME types to a known text-based language.
It uploads a null payload instead of the file content.
The AI service only receives the filename, making summarization impossible.
This issue fixes the backend to correctly pass Base64 encoded binary content to the AI service.

Acceptance Criteria

Given an uploaded image or PDF file, when the ArtifactUploadedEvent is processed, then UploadArtifactMapper should check if the file's MIME type starts with image/ or equals application/pdf.
Given an uploaded image or PDF file, when UploadArtifactMapper.toCommand is called, then it should read the raw file bytes and encode them as a Base64 string.
Given a Base64 encoded binary string, when the UploadArtifactCommand is created, then it should pass the Base64 string in the content field instead of null.
Edge case: Given an unsupported binary file (e.g., zip), when it is uploaded, then UploadArtifactMapper should continue to return null for the content.

Technical Notes

Affected Component: UploadArtifactMapper.kt in sprintstart-backend.
Implementation hint: Modify UploadArtifactMapper.toCommand to check event.mime.startsWith("image/") || event.mime == "application/pdf". Use uploadedArtifactReader.readBytes(event.artifactId) to get the raw bytes and encode them using java.util.Base64.getEncoder().encodeToString(...).

Metadata

Metadata

Labels

enhancementNew feature or requestteam:backendBackend team (sprintstart-backend, Kotlin/Spring Boot)

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions