public virtual async Task <Stream> DownloadFileAsync(FileSystemGetDto input) { var fileSystemPath = GetFileSystemPath(input.Path); fileSystemPath = Path.Combine(fileSystemPath, input.Name); var blobName = GetFileSystemRelativePath(fileSystemPath); // 去除第一个路径标识符 blobName = blobName.RemovePreFix("/", "\\"); return(await BlobContainer.GetAsync(blobName)); }
public virtual Task <FileSystemDto> GetAsync(FileSystemGetDto input) { var fileSystemPath = GetFileSystemPath(input.Path); fileSystemPath = Path.Combine(fileSystemPath, input.Name); if (File.Exists(fileSystemPath)) { var fileInfo = new FileInfo(fileSystemPath); var fileSystem = new FileSystemDto { Type = FileSystemType.File, Name = fileInfo.Name, Size = fileInfo.Length, Extension = fileInfo.Extension, CreationTime = fileInfo.CreationTime, LastModificationTime = fileInfo.LastWriteTime }; if (fileInfo.Directory != null && !fileInfo.Directory.FullName.IsNullOrWhiteSpace()) { fileSystem.Parent = GetFileSystemRelativePath(fileInfo.Directory.FullName); } return(Task.FromResult(fileSystem)); } if (Directory.Exists(fileSystemPath)) { var directoryInfo = new DirectoryInfo(fileSystemPath); var fileSystem = new FileSystemDto { Type = FileSystemType.Folder, Name = directoryInfo.Name, CreationTime = directoryInfo.CreationTime, LastModificationTime = directoryInfo.LastWriteTime }; if (directoryInfo.Parent != null && !directoryInfo.Parent.FullName.IsNullOrWhiteSpace()) { fileSystem.Parent = GetFileSystemRelativePath(directoryInfo.Parent.FullName); } return(Task.FromResult(fileSystem)); } throw new UserFriendlyException(L["FilePathNotFound"]); }
public virtual async Task <FileSystemDto> GetAsync(FileSystemGetDto input) { return(await FileSystemAppService.GetAsync(input)); }