예제 #1
0
        public async Task <IFile> FindFileAsync(string path)
        {
            if (path == null)
            {
                throw new ArgumentNullException(nameof(path));
            }

            var names = path.Split('/').Where(s => string.IsNullOrEmpty(s) == false).ToArray();

            if (names.Length < 1)
            {
                throw new ArgumentOutOfRangeException(nameof(path));
            }

            var head       = names.Take(names.Length - 1).ToArray();
            var tail       = names.Last();
            var folderPath = $"/{string.Join("/", head)}/".Replace("//", "/");
            var folder     = await _folders.GetAsync(folderPath);

            if (folder == null)
            {
                return(null);
            }

            var file = await _files.FindChildAsync(folder.Id, tail);

            if (file == null)
            {
                return(null);
            }

            return(new File
            {
                Id = file.Id,
                Path = folder.Path + tail,
                Name = file.Name,
                ContentType = file.ContentType,
                Size = file.Size,
                LastModifiedBy = file.LastModifiedBy,
                LastModifiedAt = file.LastModifiedAt,
                BinaryPath = file.BinaryPath,
                FolderId = file.FolderId
            });
        }
예제 #2
0
 public async Task <Folder> GetDetail(int id)
 {
     return(await repository.GetAsync(id));
 }