+ Start a Discussion
Swathi CseSwathi Cse 

error Blob

User-added image
How to uplaod the csv file error 'BLOB is not a valid UTF-8 string' error
Fouzan Baig AFouzan Baig A
While it does not appear to be clearly documented, having scanned a number of forum posts about this. The Blob type only supports UTF-8 encoded strings, you must ensure that the file your uploading complies with this encoding, otherwise you will get this error in cases where you have special characters.

To ensure your file is UTF-8, for example in Windows Notepad make sure that you select to save as Unicode UTF-8 in the Save As dialog, other applications will likely have a similar option (for command line this answer might be of use).

/** @param input Blob data representing correct string in
@inCharset encoding
@param inCharset encoding of the Blob data (for example 'ISO 8859-2') */
public static String blobToString(Blob input, String inCharset){
String hex = EncodingUtil.convertToHex(input);
System.assertEquals(0, hex.length() & 1);
final Integer bytesCount = hex.length() >> 1;
String[] bytes = new String[bytesCount];
for(Integer i = 0; i < bytesCount; ++i)
bytes[i] = hex.mid(i << 1, 2);
return EncodingUtil.urlDecode('%' + String.join(bytes, '%'), inCharset);
Naveen KNNaveen KN
Check the below link