Exemplo n.º 1
0
        public async Task <IFile> CopyFromAsync(IFile file, string targetPath)
        {
            Guard.ArgumentNotNull(file, nameof(file));
            if (!file.Exists)
            {
                throw new ArgumentException("要从中复制内容的源文件不存在。", nameof(file));
            }
            Guard.ArgumentIsRelativePath(targetPath, nameof(targetPath));
            string fullPath = _fileMapping.GetFilePath(targetPath, _scope);

            using (var fs = await file.CreateReadStreamAsync())
            {
                return(await CreateFileAsync(fullPath, fs));
            }
        }
Exemplo n.º 2
0
 public PhysicalFile(string scope, string filePath, IFileRequestMapping fileRequestMapping)
 {
     Guard.ArgumentNotNull(fileRequestMapping, nameof(fileRequestMapping));
     Guard.ArgumentIsRelativePath(filePath, nameof(filePath));
     _filePath = filePath;
     _fullPath = fileRequestMapping.GetFilePath(filePath, scope);
     _mapping  = fileRequestMapping;
 }
Exemplo n.º 3
0
        public Task <IFile> SaveChangesAsync()
        {
            string fullPath  = _fileMapping.GetFilePath(_relativePath, _scope);
            string directory = Path.GetDirectoryName(fullPath);

            if (!Directory.Exists(directory))
            {
                Directory.CreateDirectory(directory);
            }
            File.Copy(_tempFilePath, fullPath, true);
            return(Task.FromResult <IFile>(new PhysicalFile(_scope, _relativePath, _fileMapping)));
        }