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