Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix base64 input to addData #127

Open
sanderpick opened this issue Jun 27, 2019 · 1 comment
Open

Fix base64 input to addData #127

sanderpick opened this issue Jun 27, 2019 · 1 comment

Comments

@sanderpick
Copy link
Member

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.

@sanderpick
Copy link
Member Author

There could possibly be a correlation here with the length of the string. @asutula mentioned needing to investigate https://developer.apple.com/documentation/foundation/nsdatabase64encodingoptions?language=objc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant