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

Uploading binary data #44

Open
ssured opened this issue May 14, 2014 · 3 comments
Open

Uploading binary data #44

ssured opened this issue May 14, 2014 · 3 comments

Comments

@ssured
Copy link

ssured commented May 14, 2014

Thanks for the library!

When writing binary data to GitHub the API seems a little weird. Consider buffer to contain a gif image.

This code does not work:

branch.write({
  "image.gif": {
    isBase64: true,
    content: buffer.toString('base64')
  }
});

This code works:

branch.write({
  "image.gif": {
    isBase64: true,
    content: buffer.toString('binary')
  }
});

It feels really weird to provide a binary string and specifying isBase64

https://github.com/philschatz/octokit.js/blob/master/octokit.js#L764-L766 causes the problem. Some simple API aligning will fix the issue.

@philschatz
Copy link
Owner

Thanks for the issue. Are you using this library in NodeJS or in the browser?

Is renaming isBase64 to isBinary sufficient?

@ssured
Copy link
Author

ssured commented May 14, 2014

I am using NodeJS right now.

Yes, renaming to isBinary is sufficient.

Even nicer would be to check for a Buffer (content instanceof Buffer) object, if so, consider it binary data and call content.toString(‘base64’). Browsers < IE10 need a little care in that case http://caniuse.com/typedarrays

@Kedrigern
Copy link

Hi, I have similar problem. Is relevant? Is this solved?

Details and minimal working example.

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

3 participants