| 311 | } |
| 312 | |
| 313 | async fetchBlobContent({ sha, repoURL, parseText }: BlobArgs) { |
| 314 | const result: GitGetBlobResponse = await this.request(`${repoURL}/git/blobs/${sha}`, { |
| 315 | cache: 'force-cache', |
| 316 | }); |
| 317 | |
| 318 | if (parseText) { |
| 319 | // treat content as a utf-8 string |
| 320 | const content = Base64.decode(result.content); |
| 321 | return content; |
| 322 | } else { |
| 323 | // treat content as binary and convert to blob |
| 324 | const content = Base64.atob(result.content); |
| 325 | const byteArray = new Uint8Array(content.length); |
| 326 | for (let i = 0; i < content.length; i++) { |
| 327 | byteArray[i] = content.charCodeAt(i); |
| 328 | } |
| 329 | const blob = new Blob([byteArray]); |
| 330 | return blob; |
| 331 | } |
| 332 | } |
| 333 | |
| 334 | async listFiles( |
| 335 | path: string, |