github-tools / github-tools/github

Node.js/GitHub API - commit Image file in repository with github-api

Đang mở
#523 1 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
JavaScript
Star
3.8k
Fork
809
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

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.

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
github, javascript, node.js
Lĩnh vực
api
Loại issue
Lỗi
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Cần làm rõ
Mức phù hợp với người mới
20/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.