Skip to content

Commit 5e393cc

Browse files
committed
UTF-8 fix for text-based media types
1 parent c44c383 commit 5e393cc

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

  • src/main/java/com/atomgraph/linkeddatahub/resource/upload

src/main/java/com/atomgraph/linkeddatahub/resource/upload/Item.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import java.io.File;
2020
import java.io.FileNotFoundException;
2121
import java.net.URI;
22+
import java.nio.charset.StandardCharsets;
2223
import java.util.List;
2324
import jakarta.ws.rs.core.Context;
2425
import jakarta.ws.rs.core.Request;
@@ -282,8 +283,16 @@ public jakarta.ws.rs.core.MediaType getMediaType()
282283
if (log.isErrorEnabled()) log.error("File '{}' does not have a media type", getResource());
283284
throw new IllegalStateException("File does not have a media type (dct:format)");
284285
}
285-
286-
return com.atomgraph.linkeddatahub.MediaType.valueOf(format);
286+
287+
jakarta.ws.rs.core.MediaType mediaType = com.atomgraph.linkeddatahub.MediaType.valueOf(format);
288+
289+
// Add charset=UTF-8 for text-based media types
290+
if (mediaType.getType().equals("text"))
291+
{
292+
return mediaType.withCharset(StandardCharsets.UTF_8.name());
293+
}
294+
295+
return mediaType;
287296
}
288297

289298
/**

0 commit comments

Comments
 (0)