The input is not a valid Base-64 string as it contains a non-base64 character

后端 未结 11 1715
难免孤独
难免孤独 2020-11-27 14:37

I have a REST service that reads a file and sends it to another console application after converting it to Byte array and then to Base64 string. This part works, but when th

11条回答
  •  时光取名叫无心
    2020-11-27 15:11

    Just in case you don't know the type of uploaded image, and you just you need to remove its base64 header:

     var imageParts = model.ImageAsString.Split(',').ToList();
     //Exclude the header from base64 by taking second element in List.
     byte[] Image = Convert.FromBase64String(imageParts[1]);
    

提交回复
热议问题