github-tools / github-tools/github
Write Image to GitRepo
- Dominant language
- JavaScript
- Stars
- 3.8k
- Forks
- 809
- PR merge metrics
- No merged PRs in 30d
Description
I am trying to upload an Image to GitHub from the browser. I download the image into a blob, convert the blob into base64 and the use the writeFile method. However, the data never arrives correctly in GitHub.
```JS
fetch(url).then(response => response.blob().then(blob => {
let reader = new FileReader();
reader.onloadend = () => {
var base64result = reader.result.substr(reader.result.indexOf(',') + 1);
let fileName = this.getFileName(image.url)
repository.writeFile(this.github.branch, fileName, base64result, 'Quant-UX Export').then(result => {
resolve(result)
})
}
reader.readAsDataURL(blob);
}))
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.