Open Closed

FileManager module /file-management/directory-descriptor retured data error #4923


User avatar
0
xiexingen created
  • ABP Framework version: v7.1.0
  • Scenes

my thoughts

  • record token to cache as whitelist when user login generate token(at the same time remove this user other token)
  • while user request server vertify token check token are in cache when request .

3 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    We will fix the problem and your ticket refunded.

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    You can try

    
    CreateMap<DirectoryDescriptor, DirectoryContentDto>()
                .ForMember(dest => dest.IsDirectory,
                    opt => opt.MapFrom(src => true))
                .ForMember(dest => dest.Size,
                    opt => opt.MapFrom(src => 0))
                .ForMember(dest => dest.IconInfo,
                    opt => opt.Ignore())
                .MapExtraProperties();
    
            CreateMap<FileDescriptor, DirectoryContentDto>()
                .ForMember(dest => dest.IsDirectory,
                    opt => opt.MapFrom(src => false))
                .ForMember(dest => dest.IconInfo,
                    opt => opt.Ignore())
                .MapExtraProperties();
    
    [ExposeServices(typeof(IDirectoryDescriptorAppService))]
    public class MyDirectoryDescriptorAppService : DirectoryDescriptorAppService
    {
        public MyDirectoryDescriptorAppService(IDirectoryManager directoryManager, IFileManager fileManager, IDirectoryDescriptorRepository directoryDescriptorRepository, IFileDescriptorRepository fileDescriptorRepository, IOptions<FileIconOption> fileIconOption) : base(directoryManager, fileManager, directoryDescriptorRepository, fileDescriptorRepository, fileIconOption)
        {
        }
    
        public override async Task<PagedResultDto<DirectoryContentDto>> GetContentAsync(DirectoryContentRequestInput input)
        {
            var result = new List<DirectoryContentDto>();
            var subDirectoryCount = await DirectoryDescriptorRepository.GetChildrenCountAsync(input.Id, input.Filter);
            var subFileCount = await FileDescriptorRepository.CountDirectoryFilesAsync(input.Id, input.Filter);
    
            // directory can be orderable for only its name
            var directorySorting =
                input.Sorting?.IndexOf("name asc", StringComparison.OrdinalIgnoreCase) >= 0 ?
                    "name asc" :
                    input.Sorting?.IndexOf("name desc", StringComparison.OrdinalIgnoreCase) >= 0 ?
                        "name desc" :
                        null;
    
            var subDirectories = await DirectoryDescriptorRepository.GetChildrenAsync(input.Id, input.Filter, directorySorting, input.MaxResultCount, input.SkipCount);
            result.AddRange(ObjectMapper.Map<List<DirectoryDescriptor>, List<DirectoryContentDto>>(subDirectories));
    
            if (await AuthorizationService.IsGrantedAsync(FileManagementPermissions.FileDescriptor.Default))
            {
                var fileSkipCount = input.SkipCount <= subDirectoryCount ? 0 : input.SkipCount - subDirectoryCount;
                var fileMaxResultCount = input.MaxResultCount - subDirectories.Count;
    
                var subFiles = await FileDescriptorRepository.GetListAsync(input.Id, input.Filter, input.Sorting, fileMaxResultCount, fileSkipCount);
                var subFilesDto = ObjectMapper.Map<List<FileDescriptor>, List<DirectoryContentDto>>(subFiles);
                foreach (var fileDto in subFilesDto)
                {
                    fileDto.IconInfo = FileIconOption.GetFileIconInfo(fileDto.Name);
                    
                    result.Add(fileDto);
                }
            }
    
            return new PagedResultDto<DirectoryContentDto>(subDirectoryCount + subFileCount, result);
        }
    }
    
  • User Avatar
    0
    xiexingen created

    thanks

Made with ❤️ on ABP v9.1.0-preview. Updated on December 12, 2024, 07:15