| 654 | */ |
| 655 | getFileView(bucketId: string, fileId: string, token?: string): Promise<ArrayBuffer>; |
| 656 | getFileView( |
| 657 | paramsOrFirst: { bucketId: string, fileId: string, token?: string } | string, |
| 658 | ...rest: [(string)?, (string)?] |
| 659 | ): Promise<ArrayBuffer> { |
| 660 | let params: { bucketId: string, fileId: string, token?: string }; |
| 661 | |
| 662 | if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { |
| 663 | params = (paramsOrFirst || {}) as { bucketId: string, fileId: string, token?: string }; |
| 664 | } else { |
| 665 | params = { |
| 666 | bucketId: paramsOrFirst as string, |
| 667 | fileId: rest[0] as string, |
| 668 | token: rest[1] as string |
| 669 | }; |
| 670 | } |
| 671 | |
| 672 | const bucketId = params.bucketId; |
| 673 | const fileId = params.fileId; |
| 674 | const token = params.token; |
| 675 | |
| 676 | if (typeof bucketId === 'undefined') { |
| 677 | throw new AppwriteException('Missing required parameter: "bucketId"'); |
| 678 | } |
| 679 | |
| 680 | if (typeof fileId === 'undefined') { |
| 681 | throw new AppwriteException('Missing required parameter: "fileId"'); |
| 682 | } |
| 683 | |
| 684 | const apiPath = '/storage/buckets/{bucketId}/files/{fileId}/view'.replace('{bucketId}', bucketId).replace('{fileId}', fileId); |
| 685 | const payload: Payload = {}; |
| 686 | |
| 687 | if (typeof token !== 'undefined') { |
| 688 | payload['token'] = token; |
| 689 | } |
| 690 | |
| 691 | const uri = new URL(this.client.config.endpoint + apiPath); |
| 692 | payload['project'] = this.client.config.project; |
| 693 | |
| 694 | |
| 695 | for (const [key, value] of Object.entries(Service.flatten(payload))) { |
| 696 | uri.searchParams.append(key, value); |
| 697 | } |
| 698 | return this.client.call('get', uri, { |
| 699 | }, payload, 'arrayBuffer'); |
| 700 | } |
| 701 | |
| 702 | /** |
| 703 | * Get a file content by its unique ID. The endpoint response return with a |