Member Junction
    Preparing search index...
    • Creates a pre-authenticated download URL for a file from the specified file storage provider.

      This utility function simplifies the process of generating download URLs by instantiating the appropriate storage provider driver and delegating to its CreatePreAuthDownloadUrl method. The returned URL can be provided directly to clients for downloading the file without requiring additional authentication.

      Parameters

      • providerEntity: MJFileStorageProviderEntity

        The file storage provider entity containing connection details

      • providerKeyOrName: string

        The provider key or name of the file to download (use the ProviderKey if it was returned during upload, otherwise use the file Name)

      • OptionaluserContext: UserContextOptions

        Optional user context for OAuth providers (required if provider.RequiresOAuth is true)

      Returns Promise<string>

      A promise that resolves to the pre-authenticated download URL as a string

      // Get a pre-authenticated download URL for a file
      const fileStorageProvider = await entityMgr.FindById('FileStorageProvider', 'azure-main');

      // Using the file name
      const downloadUrl = await createDownloadUrl(fileStorageProvider, 'reports/annual-report.pdf', userContext);

      // Or using the provider key if returned during upload
      const downloadUrl = await createDownloadUrl(fileStorageProvider, file.ProviderKey, userContext);

      // The download URL can be provided to clients for direct download
      console.log(downloadUrl);