* Get a file content by its unique ID. The endpoint response return with a * 'Content-Disposition: attachment' header that tells the browser to start * downloading the file to user downloads directory. * * @param {string} bucketId * @param {string} fileId * @param {stri
(bucketId: string, fileId: string, token?: string)
| 711 | * @returns {URL} |
| 712 | */ |
| 713 | getFileDownloadURL(bucketId: string, fileId: string, token?: string): URL { |
| 714 | const apiPath = '/storage/buckets/{bucketId}/files/{fileId}/download'.replace('{bucketId}', bucketId).replace('{fileId}', fileId); |
| 715 | const payload: Payload = {}; |
| 716 | |
| 717 | if (typeof token !== 'undefined') { |
| 718 | payload['token'] = token; |
| 719 | } |
| 720 | |
| 721 | const uri = new URL(this.client.config.endpoint + apiPath); |
| 722 | payload['project'] = this.client.config.project; |
| 723 | |
| 724 | for (const [key, value] of Object.entries(Service.flatten(payload))) { |
| 725 | uri.searchParams.append(key, value); |
| 726 | } |
| 727 | |
| 728 | return uri; |
| 729 | } |
| 730 | |
| 731 | /** |
| 732 | * Get a file preview image. Currently, this method supports preview for image |