fix(ancpi): strip diacritics from MinIO metadata headers (ASCII only)
This commit is contained in:
@@ -89,10 +89,17 @@ export async function storeCfExtract(
|
||||
// Store in subfolder per cadastral number
|
||||
const path = `parcele/${nrCadastral}/${fileName}`;
|
||||
|
||||
await minioClient.putObject(BUCKET, path, pdfBuffer, pdfBuffer.length, {
|
||||
// Strip diacritics from metadata values — MinIO headers only accept ASCII
|
||||
const safeMetadata: Record<string, string> = {
|
||||
"Content-Type": "application/pdf",
|
||||
...metadata,
|
||||
});
|
||||
};
|
||||
for (const [key, value] of Object.entries(metadata)) {
|
||||
safeMetadata[key] = value
|
||||
.normalize("NFD")
|
||||
.replace(/[\u0300-\u036f]/g, "");
|
||||
}
|
||||
|
||||
await minioClient.putObject(BUCKET, path, pdfBuffer, pdfBuffer.length, safeMetadata);
|
||||
|
||||
console.log(
|
||||
`[epay-storage] Stored: ${path} (${pdfBuffer.length} bytes)`,
|
||||
|
||||
Reference in New Issue
Block a user