MCPcopy Index your code
hub / github.com/appwrite/sdk-for-react-native / getFilePreviewURL

Method getFilePreviewURL

src/services/storage.ts:755–815  ·  view source on GitHub ↗

* Get a file preview image. Currently, this method supports preview for image * files (jpg, png, and gif), other supported formats, like pdf, docs, slides, * and spreadsheets, will return the file icon image. You can also pass query * string arguments for cutting and resizing your pre

(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)

Source from the content-addressed store, hash-verified

753 * @returns {URL}
754 */
755 getFilePreviewURL(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): URL {
756 const apiPath = '/storage/buckets/{bucketId}/files/{fileId}/preview'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
757 const payload: Payload = {};
758
759 if (typeof width !== 'undefined') {
760 payload['width'] = width;
761 }
762
763 if (typeof height !== 'undefined') {
764 payload['height'] = height;
765 }
766
767 if (typeof gravity !== 'undefined') {
768 payload['gravity'] = gravity;
769 }
770
771 if (typeof quality !== 'undefined') {
772 payload['quality'] = quality;
773 }
774
775 if (typeof borderWidth !== 'undefined') {
776 payload['borderWidth'] = borderWidth;
777 }
778
779 if (typeof borderColor !== 'undefined') {
780 payload['borderColor'] = borderColor;
781 }
782
783 if (typeof borderRadius !== 'undefined') {
784 payload['borderRadius'] = borderRadius;
785 }
786
787 if (typeof opacity !== 'undefined') {
788 payload['opacity'] = opacity;
789 }
790
791 if (typeof rotation !== 'undefined') {
792 payload['rotation'] = rotation;
793 }
794
795 if (typeof background !== 'undefined') {
796 payload['background'] = background;
797 }
798
799 if (typeof output !== 'undefined') {
800 payload['output'] = output;
801 }
802
803 if (typeof token !== 'undefined') {
804 payload['token'] = token;
805 }
806
807 const uri = new URL(this.client.config.endpoint + apiPath);
808 payload['project'] = this.client.config.project;
809
810 for (const [key, value] of Object.entries(Service.flatten(payload))) {
811 uri.searchParams.append(key, value);
812 }

Callers

nothing calls this directly

Calls 1

flattenMethod · 0.80

Tested by

no test coverage detected