| 708 | } |
| 709 | |
| 710 | async fetchBlobContent({ sha, repoURL, parseText }: BlobArgs) { |
| 711 | const result: Endpoints['GET /repos/{owner}/{repo}/git/blobs/{file_sha}']['response']['data'] = |
| 712 | await this.request(`${repoURL}/git/blobs/${sha}`, { |
| 713 | cache: 'force-cache', |
| 714 | }); |
| 715 | |
| 716 | if (parseText) { |
| 717 | // treat content as a utf-8 string |
| 718 | const content = Base64.decode(result.content); |
| 719 | return content; |
| 720 | } else { |
| 721 | // treat content as binary and convert to blob |
| 722 | const content = Base64.atob(result.content); |
| 723 | const byteArray = new Uint8Array(content.length); |
| 724 | for (let i = 0; i < content.length; i++) { |
| 725 | byteArray[i] = content.charCodeAt(i); |
| 726 | } |
| 727 | const blob = new Blob([byteArray]); |
| 728 | return blob; |
| 729 | } |
| 730 | } |
| 731 | |
| 732 | async listFiles( |
| 733 | path: string, |