resolveBytesExtension static method
Binary uploads have no source path. Preserve PNG output while retaining legacy defaults for other formats/callers (repository API stays unchanged).
Implementation
static String resolveBytesExtension(List<int> bytes, MediaType mediaType) {
const png = [137, 80, 78, 71, 13, 10, 26, 10];
if (mediaType == MediaType.image && bytes.length >= png.length) {
var matches = true;
for (var i = 0; i < png.length; i++) {
if (bytes[i] != png[i]) matches = false;
}
if (matches) return '.png';
}
return defaultExtensionFor(mediaType);
}