Skip to content

Commit 84b71af

Browse files
committed
Use file model MIME type instead of S3 content type
GetFileBase64 read the MIME type from the S3 response header, which can be application/octet-stream for files uploaded without an explicit content type. Use file.GetMimeType() from the database instead, which stores the correct MIME type captured at upload time. This fixes evidence description failures when calling the OpenAI API with PDF files. Signed-off-by: Bryan Frimin <bryan@getprobo.com>
1 parent 644061f commit 84b71af

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

pkg/filemanager/service.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,8 @@ func (s *Service) GetFileBase64(
6565
return "", "", fmt.Errorf("cannot read file data: %w", err)
6666
}
6767

68-
if result.ContentType == nil || *result.ContentType == "" {
69-
return "", "", fmt.Errorf("no MIME type available for file %s", file.GetObjectKey())
70-
}
71-
7268
base64Data = base64.StdEncoding.EncodeToString(fileData)
73-
mimeType = *result.ContentType
69+
mimeType = file.GetMimeType()
7470

7571
return base64Data, mimeType, nil
7672
}

0 commit comments

Comments
 (0)