Member Junction
    Preparing search index...

    Function copyObjectBetweenProviders

    • Copies a file from one storage provider to another.

      This utility function enables transferring files between different storage providers (e.g., from Dropbox to Google Drive, or from S3 to Azure). The transfer happens server-side, so the file data flows: Source Provider → Server → Destination Provider.

      Parameters

      • sourceProviderEntity: MJFileStorageProviderEntity

        The source file storage provider entity

      • destinationProviderEntity: MJFileStorageProviderEntity

        The destination file storage provider entity

      • sourcePath: string

        The path to the file in the source provider

      • destinationPath: string

        The path where the file should be saved in the destination provider

      • Optionaloptions: CopyBetweenProvidersOptions

        Optional user context for OAuth providers

      Returns Promise<CopyBetweenProvidersResult>

      A promise that resolves to a CopyBetweenProvidersResult

      // Copy a file from Dropbox to Google Drive
      const sourceProvider = await entityMgr.FindById('FileStorageProvider', 'dropbox-id');
      const destProvider = await entityMgr.FindById('FileStorageProvider', 'gdrive-id');

      const result = await copyObjectBetweenProviders(
      sourceProvider,
      destProvider,
      'documents/report.pdf',
      'imported/report.pdf',
      {
      sourceUserContext: { userID: currentUser.ID, contextUser },
      destinationUserContext: { userID: currentUser.ID, contextUser }
      }
      );

      if (result.success) {
      console.log(`Transferred ${result.bytesTransferred} bytes`);
      }