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

Allow binary blobs #23

Open
hannesl opened this issue Oct 28, 2012 · 4 comments
Open

Allow binary blobs #23

hannesl opened this issue Oct 28, 2012 · 4 comments

Comments

@hannesl
Copy link

hannesl commented Oct 28, 2012

In order to safely transfer binary blobs/filtes, the API needs to use base64 encoding when appropriate. postBlob() however always uses "utf-8". So there needs to be either an additional argument in write() and postBlob() that specifies the encoding, or postBlob() needs to detect if the file is binary or not, and adjust the encoding automatically.

This little snippet seems to be able to detect binary data:

/[\x00-\x08\x0E-\x1F]/.test(data)

See http://stackoverflow.com/questions/1677644/detect-non-printable-characters-in-javascript

I'm currently dealing with similar issues in Prose: prose/prose#255

@hannesl
Copy link
Author

hannesl commented Oct 28, 2012

Or, should the recommended approach be that implementors of the API encode the data before calling write()? I guess that would work too.

@mattpass
Copy link
Collaborator

@hannesl Sorry for delay in replying here, I'm helping Michael clear old issues.

Good points and a tricky one. I'd be hesitant to auto encode anything without the user being aware of it, but then I can see encoding as being useful. Probably the best solution here is to encode it before calling on the API. However if you do want to put in a pull request re encoding I'd look at it, but would have to be as an optional argument.

@aendra-rininsland
Copy link
Member

@mattpass Was this ever dealt with? There seems to be some binary file handling in postBlob, which I'm looking at briefly due to #149.

@mattpass
Copy link
Collaborator

mattpass commented Apr 6, 2015

@Aendrew Nope, was awaiting a pull request and going to check that out. Nothing submitted or coded by myself here.

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

No branches or pull requests

3 participants