github-tools / github-tools/github
Can't post a proper blob for a binary file
- 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ả
So I'm trying to do create a blob with `createBlob` for a PNG image from a browser. I've taken a look in the tests and specifically in the [imageBlob fixture](https://github.com/github-tools/github/blob/master/test/fixtures/imageBlob.js), but it doesn't seem to work. You can see an example [here](https://github.com/illia-kolodiazhnyi/github-api-test/blob/barbar/file.png) of what's happening when I try to put the result of `reader.readAsBinaryString` as `createBlob()` parameter.
I've managed to get it working with following steps only:
1. read the image file like `readAsDataURL(image)` to get the Base64 representation
2. remove the MIME type from the string with `content = content.replace(/^(.+,)/, '')`
3. make a change in my local copy of the library (**!**) for `createBlob` funciton:
```
if (typeof content === 'object') {
postBody = content;
} else {
postBody = this._getContentObject(content);
}
```
4. use `createBlob({content: content, encoding: 'base64'})`
Interesting thing is that there used to be a way to do it without interfering the library code ([PR#103](https://github.com/github-tools/github/pull/103), but it's gone with removing the `github.js` file.
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
Inspect the createBlob implementation and the test/fixtures/imageBlob.js fixture, then reproduce the browser upload using the issue's PNG example and readAsBinaryString path. Compare the request body and encoding with the working Base64 workaround. Done means a valid binary PNG blob can be created without modifying the library locally, with a regression test covering the supported input.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- javascript
- 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
- Khá rõ ràng
- Mức phù hợp với người mới
- 48/100