github-tools / github-tools/github

Write Image to GitRepo

未关闭
#655 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
JavaScript
星标
3.8k
派生
809
PR 合并指标
30 天内没有已合并 PR

描述

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);
}))
```

贡献指南

这个仓库没有索引到贡献指南

调研方向

首先跟踪浏览器封装器中的 repository.writeFile 调用,并比较其对 FileReader 生成的 base64result 的处理方式。使用所示的 fetch 和 writeFile 序列重现图片上传;上传的图片能够正确到达 GitHub 即表示完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
javascript
领域
api
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。