github-tools / github-tools/github
Node.js/GitHub API - commit Image file in repository with github-api
- 主要语言
- JavaScript
- 星标
- 3.8k
- 派生
- 809
- PR 合并指标
- 30 天内没有已合并 PR
描述
I extracted a dataURL from a canvas and I want to send this content to my GitHub Repository using 'github-api': http://github-tools.github.io/github/docs/3.1.0/Repository.html#writeFile
I can do commit but only with a String and on GitHub I can see the file with the dataURL. On GitHub if I click on the image committed with api I can see that: "data:image/jpeg;charset=utf-8;base64, dataURL......", but I would like to display image, not the dataURL String. Can you explain this passage to me please?
`var options = {`
`author: {name: nickname, email: mail},`
`committer: {name: nickname, email: mail},`
`encode: true,`
`}`
`var image = req.body.file_jpeg_data; //dataURL from canvas`
`var data = image.replace(/^data:image\/(jpeg);base64,/,'');`
`var buf = new Buffer(data, 'base64').toString('base64');`
`//commit on my GitHub Repository with github-api`
`repo.writeFile('master','revision.jpeg',buf,'commit message',options, function(err){`
`});`
When I clone the repository I would like to display my JPEG file, but this file is corrupt. If I enter dataURL generated by commit on a Base64-Image Converter, the file is a really image.
贡献指南
这个仓库没有索引到贡献指南
调研方向
Start with the Repository.writeFile documentation linked in the issue and the github-api implementation of writeFile, then trace how the encode option handles the supplied data. Reproduce the reported commit and clone the repository to compare the stored bytes with a valid JPEG; done means the committed revision opens as an image rather than displaying the data URL.
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- github, javascript, node.js
- 领域
- api
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 需要澄清
- 新手友好度
- 20/100