refactoring fs
This commit is contained in:
parent
c47e2b4621
commit
5617a543eb
8 changed files with 98 additions and 68 deletions
|
|
@ -1,11 +0,0 @@
|
|||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using Microsoft.AspNet.Http;
|
||||
|
||||
public class BlogFilesPost {
|
||||
[Required]
|
||||
public long PostId {get; set; }
|
||||
[Required]
|
||||
public IList<IFormFile> File { get; set; }
|
||||
}
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
using System;
|
||||
|
||||
namespace Yavsc.ViewModels
|
||||
{
|
||||
public class FileInfo
|
||||
{
|
||||
|
||||
public string PermanentUri { get; set; }
|
||||
public string Name { get; set; }
|
||||
|
||||
public int Size { get; set; }
|
||||
|
||||
public DateTime Creation { get; set; }
|
||||
|
||||
public string MimeType { get; set; }
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
35
Yavsc/ViewModels/UserFiles/UserDirectoryInfo.cs
Normal file
35
Yavsc/ViewModels/UserFiles/UserDirectoryInfo.cs
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Yavsc.Helpers;
|
||||
|
||||
namespace Yavsc.ViewModels.UserFiles
|
||||
{
|
||||
public class UserDirectoryInfo
|
||||
{
|
||||
public string SubPath { get; private set; }
|
||||
public UserFileInfo [] Files {
|
||||
get; private set;
|
||||
}
|
||||
public string [] SubDirectories {
|
||||
get; private set;
|
||||
}
|
||||
private DirectoryInfo dInfo;
|
||||
public UserDirectoryInfo(string username, string path)
|
||||
{
|
||||
SubPath = (path==null) ? username : username + Path.DirectorySeparatorChar + path;
|
||||
if ( !SubPath.IsValidPath() )
|
||||
throw new InvalidOperationException(
|
||||
$"File name contains invalid chars, using path {SubPath}");
|
||||
|
||||
dInfo = new DirectoryInfo(
|
||||
Path.Combine(Startup.UserFilesDirName,SubPath));
|
||||
Files = dInfo.GetFiles().Select
|
||||
( entry => new UserFileInfo { Name = entry.Name, Size = entry.Length,
|
||||
CreationTime = entry.CreationTime, LastModified = entry.LastWriteTime }).ToArray();
|
||||
SubDirectories = dInfo.GetDirectories().Select
|
||||
( d=> d.Name ).ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
17
Yavsc/ViewModels/UserFiles/UserFileInfo.cs
Normal file
17
Yavsc/ViewModels/UserFiles/UserFileInfo.cs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
using System;
|
||||
|
||||
namespace Yavsc.ViewModels
|
||||
{
|
||||
public class UserFileInfo
|
||||
{
|
||||
|
||||
public string Name { get; set; }
|
||||
|
||||
public long Size { get; set; }
|
||||
|
||||
public DateTime CreationTime { get; set; }
|
||||
|
||||
public DateTime LastModified { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue