@grabjs/superapp-sdk
    Preparing search index...

    Class FileModule

    JSBridge module for downloading files to the user's device.

    Initiates native file download handling in the Grab app using a file URL and file name. This code must run on the Grab SuperApp's WebView to function correctly.

    ES Module:

    import { FileModule } from '@grabjs/superapp-sdk';
    const fileModule = new FileModule();

    CDN (UMD):

    <script src="https://cdn.jsdelivr.net/npm/@grabjs/superapp-sdk/dist/index.js"></script>
    <script>
    const fileModule = new SuperAppSDK.FileModule();
    </script>

    Hierarchy (View Summary)

    Index

    Constructors

    Methods

    Constructors

    Methods

    • Downloads a file via the native bridge.

      Parameters

      Returns Promise<DownloadFileResponse>

      Download operation result.

      Simple usage

      import { FileModule, isSuccess, isErrorResponse } from '@grabjs/superapp-sdk';

      // Initialize the file module
      const file = new FileModule();

      // Download the file
      const response = await file.downloadFile({
      fileUrl: 'https://example.com/report.pdf',
      fileName: 'report.pdf',
      });

      // Handle the response
      if (isSuccess(response)) {
      console.log('File downloaded successfully');
      } else if (isErrorResponse(response)) {
      console.error(`Error ${response.status_code}: ${response.error}`);
      } else {
      console.error('Unhandled response');
      }