2020-01-16 05:06:25 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Microsoft.AspNetCore.Http;
|
|
|
|
|
using MongoDB.Bson.Serialization.Attributes;
|
|
|
|
|
using Wabbajack.Common;
|
|
|
|
|
using Path = Alphaleonis.Win32.Filesystem.Path;
|
|
|
|
|
|
|
|
|
|
namespace Wabbajack.BuildServer.Models
|
|
|
|
|
{
|
|
|
|
|
public class UploadedFile
|
|
|
|
|
{
|
|
|
|
|
public string Id { get; set; }
|
|
|
|
|
public string Name { get; set; }
|
|
|
|
|
public long Size { get; set; }
|
|
|
|
|
public string Hash { get; set; }
|
|
|
|
|
public string Uploader { get; set; }
|
|
|
|
|
public DateTime UploadDate { get; set; } = DateTime.UtcNow;
|
2020-01-21 12:49:49 +00:00
|
|
|
|
|
|
|
|
|
public string CDNName { get; set; }
|
2020-01-16 05:06:25 +00:00
|
|
|
|
|
|
|
|
|
[BsonIgnore]
|
2020-01-18 22:09:32 +00:00
|
|
|
|
public string MungedName => $"{Path.GetFileNameWithoutExtension(Name)}-{Id}{Path.GetExtension(Name)}";
|
2020-01-16 05:06:25 +00:00
|
|
|
|
|
2020-01-21 12:49:49 +00:00
|
|
|
|
[BsonIgnore]
|
|
|
|
|
public string Uri => CDNName == null ? $"https://wabbajack.b-cdn.net/{MungedName}" : $"https://{CDNName}.b-cdn.net/{MungedName}";
|
2020-01-16 05:06:25 +00:00
|
|
|
|
}
|
|
|
|
|
}
|