I have an apex method that takes in a Blob input argument and needs to be called from javascript. When I pass in a Javascript Blob, I get what seems to a be type mismatch error from VFRemote.js:

"Visualforce Remoting Exception: Unexpected type for TestClass.testRemoteAction(Blob)" {statusCode: 400, type: "exception", tid: 2, ref: false, action: "TestClass", method: "testRemoteAction", message: "Unexpected type for TestClass.testRemoteAction(Blob)", where: "", data: Array[1], vfTx: true, 2 more…} VFRemote.js:116 null

Here's my javascript snippet:

var binaryMsg = new Uint8Array(message);
var blobMsg = new Blob(binaryMsg, {type: "octet-stream"});
   function(result, event) {console.log(result);}

You can't directly construct Blobs through remoting right now. You are basically limited to things that you can put in JSON, which means that you need to make the payload binary-safe. Encode the contents in either Base64 encoding or URL-encoding, then decode it on the server side using one of the functions available for that purpose.

|improve this answer|||||

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.