I'm building a Google Drive integration to push files over. I have it working--with one significant problem. When I query VersionData from ContentVersion it return a blob.

When I pass my blob in the body of a call, it passes the string [Blob ####]. Normally, I'd use the Blob.toString() method, but this only works if the file is UTF-8 encoded, which I can't guarantee. If it isn't UTF-8, it throws this:

BLOB is not a valid UTF-8 string

Does anyone have any recommendations for how to get the actual file body? Encoding to base 64 (ie EncodingUtil.Base64Encode) does not work.


I found a solution--its on the Google Side. You can pass the base64 encoded body, and when done properly, get it decoded on the other side which eliminates the need for decoding in apex.

However, if anyone needs to decode a file in apex, this might do the trick

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.