github-tools / github-tools/github
Node.js/GitHub API - commit Image file in repository with github-api
- Vorherrschende Sprache
- JavaScript
- Sterne
- 3.8k
- Forks
- 809
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
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.
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Rechercherichtung
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.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- github, javascript, node.js
- Bereich
- api
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Muss geklärt werden
- Anfängerfreundlichkeit
- 20/100