Member Junction
    Preparing search index...

    Variable moveObjectConst

    moveObject: (
        providerEntity: MJFileStorageProviderEntity,
        oldProviderKeyOrName: string,
        newProviderKeyOrName: string,
        userContext?: UserContextOptions,
    ) => Promise<boolean> = MoveObject

    Type Declaration

      • (
            providerEntity: MJFileStorageProviderEntity,
            oldProviderKeyOrName: string,
            newProviderKeyOrName: string,
            userContext?: UserContextOptions,
        ): Promise<boolean>
      • Moves an object from one location to another within the specified file storage provider.

        This utility function handles moving files by instantiating the appropriate storage provider driver and delegating to its MoveObject method. It can be used to rename files or move them to different directories within the same storage provider.

        Parameters

        • providerEntity: MJFileStorageProviderEntity

          The file storage provider entity containing connection details

        • oldProviderKeyOrName: string

          The key or name of the object's current location (use the ProviderKey if it was returned during upload, otherwise use the file Name)

        • newProviderKeyOrName: string

          The key or name for the object's new location

        • 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 move operation was successful

        // Move a file from one location to another
        const fileStorageProvider = await entityMgr.FindById('FileStorageProvider', 'azure-main');

        // Move a file to a different directory
        const success = await moveObject(
        fileStorageProvider,
        'drafts/report.docx',
        'published/final-report.docx',
        userContext
        );

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

    Use MoveObject.