Skip to content

Fix base64 input to addData #127

@sanderpick

Description

@sanderpick

Just flagging this for later and adding the context. There seems to be an issue with how Objective-C is decoding base64 strings in the RN bridge method addData:

  1. This is the same weirdness we saw with pb.Strings
  2. The actual error we saw is from hitting the textile JSON mill with invalid JSON:
error adding data  (\351\307\370\272&start","target":"P7W358aNqdqeYFCSQJL5LobnKYfcQRaXMPogafxkE4sWHokf","duration":86400}: invalid character '(' looking for beginning of value

There seems to be some additional characters added to the start of the string (looks sorta like ASCII, but not quite?).

As a temp fix, we're just passing an encoded string all the way down to the textile lib. However, this should not effect the user TS API, which can internally encode the Buffer to base64 and pass the result to the RN bridge. This makes for a nicer API (the user should not need to deal with base64):

addData(Buffer.from(myString), <threadID>, <caption>)

vs.

addData(Buffer.from(myString).toString('base64'), <threadID>, <caption>)

This would still work with the current temporary fix in the RN bridge, because the issue is not with the JS Buffer module.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions