Sub Document insertion fails when value has binary data


#1

Hi,

I am trying to insert a sub-document having a binary data, but the insertion is failing.
The document id “key” already exist and is a json document.
“key”
{ “hello”: “world” }

– Code –
printf(“Adding new ‘binary’ path to document\n”);
LCB_CMD_SET_KEY(&cmd, “key”, 3);
cmd.specs = &spec;
cmd.nspecs = 1;

spec.sdcmd = LCB_SDCMD_DICT_UPSERT;
char *path = "binary";
LCB_SDSPEC_SET_PATH(&spec, path, strlen(path));
char buf[5];
memset(buf,1,sizeof(buf));
LCB_SDSPEC_SET_VALUE(&spec, buf, 5);

rc = lcb_subdoc3(instance, NULL, &cmd);
assert(rc == LCB_SUCCESS);
lcb_wait(instance);

– Error –
Got callback for SDMUTATE… Status: 0x44. Value:


#2

JSON specification does not allow binary data. And 0x44 code says that. Check with lcb_strerror.


#3

Java SDK does allow the same and seems to peforming base64 encoding to the json attribute containing bytearray as value. C SDK, should also be providing the support for the same