in src/Microsoft.Azure.WebJobs.Extensions.Kafka/Trigger/KafkaEventDataConvertManager.cs [95:117]
private Task<object> ConvertToByteArray(object src, Attribute attribute, ValueBindingContext context)
{
object result = null;
var value = ((IKafkaEventData)src).Value;
if (value is byte[] bytes)
{
result = bytes;
}
else if (value is null)
{
result = new byte[0];
}
else if (value is string stringValue)
{
result = Encoding.UTF8.GetBytes(stringValue);
}
else
{
logger.LogWarning($@"Unable to convert incoming data to byte[] as underlying data stream was not byte[]. Returning [null]");
}
return Task.FromResult(result);
}