You need to sign in to do that
Don't have an account?
linganna
System.StringException: BLOB is not a valid UTF-8 string
Hi all
when I uplaod csv file Iam getting the above error .
anybody help me
System.StringException: BLOB is not a valid UTF-8 string
You can't convert "BINARY" data into a String. A String only supports valid UTF-8 strings. Use EncodingUtil.Base64Encode if you need the binary data in a string you can work with.
I'm getting that error when I try to uplaod a UTF-8 file as an attachment. The strange thing is that when I try it as a document, it works fine. So I wanted to parse a txt file (UTF-8) on a trigger and since you can do triggers on attachments but not on documents, I thought I'd upload it as an attachment and parse it on insert. No such luck. Is there a difference between the body of an attachment and that of a document?
Interesting. It's a limitation of the design of attachment triggers. In a trigger, "attachment.body" is truncated or something... it's not null, but it fails on the Blob.toString() function. So, you have to actually query the db to get the contents. I got something like that working using this basic trigger:
Depending on your needs, you may want to check the content type first and/or ignore bulk updates.
https://www.codengine.in/2019/06/blob-is-not-a-valid-utf-8-string-salesforce-apex.html