| 683 | } |
| 684 | |
| 685 | async fetchBlobContent({ sha, repoURL, parseText }: BlobArgs) { |
| 686 | const result: Endpoints['GET /repos/{owner}/{repo}/git/blobs/{file_sha}']['response']['data'] = |
| 687 | await this.request(`${repoURL}/git/blobs/${sha}`, { |
| 688 | cache: 'force-cache', |
| 689 | }); |
| 690 | |
| 691 | if (parseText) { |
| 692 | // treat content as a utf-8 string |
| 693 | const content = Base64.decode(result.content); |
| 694 | return content; |
| 695 | } else { |
| 696 | // treat content as binary and convert to blob |
| 697 | const content = Base64.atob(result.content); |
| 698 | const byteArray = new Uint8Array(content.length); |
| 699 | for (let i = 0; i < content.length; i++) { |
| 700 | byteArray[i] = content.charCodeAt(i); |
| 701 | } |
| 702 | const blob = new Blob([byteArray]); |
| 703 | return blob; |
| 704 | } |
| 705 | } |
| 706 | |
| 707 | async listFiles( |
| 708 | path: string, |