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

Method getFileDownload

src/services/storage.ts:434–478  ·  view source on GitHub ↗
(
        paramsOrFirst: { bucketId: string, fileId: string, token?: string } | string,
        ...rest: [(string)?, (string)?]    
    )

Source from the content-addressed store, hash-verified

432 */
433 getFileDownload(bucketId: string, fileId: string, token?: string): Promise<ArrayBuffer>;
434 getFileDownload(
435 paramsOrFirst: { bucketId: string, fileId: string, token?: string } | string,
436 ...rest: [(string)?, (string)?]
437 ): Promise<ArrayBuffer> {
438 let params: { bucketId: string, fileId: string, token?: string };
439
440 if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
441 params = (paramsOrFirst || {}) as { bucketId: string, fileId: string, token?: string };
442 } else {
443 params = {
444 bucketId: paramsOrFirst as string,
445 fileId: rest[0] as string,
446 token: rest[1] as string
447 };
448 }
449
450 const bucketId = params.bucketId;
451 const fileId = params.fileId;
452 const token = params.token;
453
454 if (typeof bucketId === 'undefined') {
455 throw new AppwriteException('Missing required parameter: "bucketId"');
456 }
457
458 if (typeof fileId === 'undefined') {
459 throw new AppwriteException('Missing required parameter: "fileId"');
460 }
461
462 const apiPath = '/storage/buckets/{bucketId}/files/{fileId}/download'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
463 const payload: Payload = {};
464
465 if (typeof token !== 'undefined') {
466 payload['token'] = token;
467 }
468
469 const uri = new URL(this.client.config.endpoint + apiPath);
470 payload['project'] = this.client.config.project;
471
472
473 for (const [key, value] of Object.entries(Service.flatten(payload))) {
474 uri.searchParams.append(key, value);
475 }
476 return this.client.call('get', uri, {
477 }, payload, 'arrayBuffer');
478 }
479
480 /**
481 * 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 preview image. Preview is supported only for image files smaller than 10MB.

Callers

nothing calls this directly

Calls 2

flattenMethod · 0.80
callMethod · 0.80

Tested by

no test coverage detected