github-tools / github-tools/github
Node.js/GitHub API - commit Image file in repository with github-api
- Linguagem predominante
- JavaScript
- Estrelas
- 3.8k
- Forks
- 809
- Métricas de merge de PRs
- Nenhum PR com merge em 30d
Descrição
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.
Guia de contribuição
Nenhum guia de contribuição indexado para este repositório
Avaliação
Esta issue ainda não foi avaliada.