Member Junction
    Preparing search index...
    • Copies an object from one location to another within the specified file storage provider.

      This utility function handles copying files by instantiating the appropriate storage provider driver and delegating to its CopyObject method. It can be used to duplicate files within the same storage provider, either in the same folder with a different name or to a different folder.

      Parameters

      • providerEntity: MJFileStorageProviderEntity

        The file storage provider entity containing connection details

      • sourceProviderKeyOrName: string

        The key or name of the source file to copy

      • destinationProviderKeyOrName: string

        The key or name for the destination copy

      • OptionaluserContext: UserContextOptions

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

      Returns Promise<boolean>

      A promise that resolves to a boolean indicating whether the copy was successful

      const success = await copyObject(
      providerEntity,
      'documents/report.pdf',
      'documents/archive/report-2024.pdf',
      userContext
      );

      if (success) {
      console.log('File successfully copied');
      } else {
      console.log('Failed to copy file');
      }