| 521 | */ |
| 522 | getFilePreview(bucketId: string, fileId: string, width?: number, height?: number, gravity?: ImageGravity, quality?: number, borderWidth?: number, borderColor?: string, borderRadius?: number, opacity?: number, rotation?: number, background?: string, output?: ImageFormat, token?: string): Promise<ArrayBuffer>; |
| 523 | getFilePreview( |
| 524 | paramsOrFirst: { bucketId: string, fileId: string, width?: number, height?: number, gravity?: ImageGravity, quality?: number, borderWidth?: number, borderColor?: string, borderRadius?: number, opacity?: number, rotation?: number, background?: string, output?: ImageFormat, token?: string } | string, |
| 525 | ...rest: [(string)?, (number)?, (number)?, (ImageGravity)?, (number)?, (number)?, (string)?, (number)?, (number)?, (number)?, (string)?, (ImageFormat)?, (string)?] |
| 526 | ): Promise<ArrayBuffer> { |
| 527 | let params: { bucketId: string, fileId: string, width?: number, height?: number, gravity?: ImageGravity, quality?: number, borderWidth?: number, borderColor?: string, borderRadius?: number, opacity?: number, rotation?: number, background?: string, output?: ImageFormat, token?: string }; |
| 528 | |
| 529 | if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { |
| 530 | params = (paramsOrFirst || {}) as { bucketId: string, fileId: string, width?: number, height?: number, gravity?: ImageGravity, quality?: number, borderWidth?: number, borderColor?: string, borderRadius?: number, opacity?: number, rotation?: number, background?: string, output?: ImageFormat, token?: string }; |
| 531 | } else { |
| 532 | params = { |
| 533 | bucketId: paramsOrFirst as string, |
| 534 | fileId: rest[0] as string, |
| 535 | width: rest[1] as number, |
| 536 | height: rest[2] as number, |
| 537 | gravity: rest[3] as ImageGravity, |
| 538 | quality: rest[4] as number, |
| 539 | borderWidth: rest[5] as number, |
| 540 | borderColor: rest[6] as string, |
| 541 | borderRadius: rest[7] as number, |
| 542 | opacity: rest[8] as number, |
| 543 | rotation: rest[9] as number, |
| 544 | background: rest[10] as string, |
| 545 | output: rest[11] as ImageFormat, |
| 546 | token: rest[12] as string |
| 547 | }; |
| 548 | } |
| 549 | |
| 550 | const bucketId = params.bucketId; |
| 551 | const fileId = params.fileId; |
| 552 | const width = params.width; |
| 553 | const height = params.height; |
| 554 | const gravity = params.gravity; |
| 555 | const quality = params.quality; |
| 556 | const borderWidth = params.borderWidth; |
| 557 | const borderColor = params.borderColor; |
| 558 | const borderRadius = params.borderRadius; |
| 559 | const opacity = params.opacity; |
| 560 | const rotation = params.rotation; |
| 561 | const background = params.background; |
| 562 | const output = params.output; |
| 563 | const token = params.token; |
| 564 | |
| 565 | if (typeof bucketId === 'undefined') { |
| 566 | throw new AppwriteException('Missing required parameter: "bucketId"'); |
| 567 | } |
| 568 | |
| 569 | if (typeof fileId === 'undefined') { |
| 570 | throw new AppwriteException('Missing required parameter: "fileId"'); |
| 571 | } |
| 572 | |
| 573 | const apiPath = '/storage/buckets/{bucketId}/files/{fileId}/preview'.replace('{bucketId}', bucketId).replace('{fileId}', fileId); |
| 574 | const payload: Payload = {}; |
| 575 | |
| 576 | if (typeof width !== 'undefined') { |
| 577 | payload['width'] = width; |
| 578 | } |
| 579 | |
| 580 | if (typeof height !== 'undefined') { |