修改续传key的构建,修改删除续传信息时失败的bug,添加测试
This commit is contained in:
@@ -4,6 +4,7 @@ using Microsoft.Extensions.Logging;
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@@ -36,7 +37,7 @@ namespace Ufangx.FileServices.Caching
|
|||||||
throw new ArgumentException("message", nameof(fileName));
|
throw new ArgumentException("message", nameof(fileName));
|
||||||
}
|
}
|
||||||
|
|
||||||
string cleanKey = $"StoreName={storeName}&FileName={fileName}&FileType={fileType}&FileSize={fileSize}&BlobSize={blobSize}&BlobCount={blobCount}&user={contextAccessor?.HttpContext?.User?.Identity?.Name}";
|
string cleanKey = $"StoreName={Path.GetDirectoryName(storeName).Replace('\\','/').ToLower()}&FileName={fileName.ToLower()}&FileType={fileType?.ToLower()}&FileSize={fileSize}&BlobSize={blobSize}&BlobCount={blobCount}&user={contextAccessor?.HttpContext?.User?.Identity?.Name?.ToLower()}";
|
||||||
byte[] data;
|
byte[] data;
|
||||||
using (var md5 = MD5.Create())
|
using (var md5 = MD5.Create())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>netstandard2.0;netcoreapp2.0;netstandard2.1;netcoreapp3.0</TargetFrameworks>
|
<TargetFrameworks>netstandard2.0;netcoreapp2.0;netstandard2.1;netcoreapp3.0</TargetFrameworks>
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
<RepositoryType>git</RepositoryType>
|
<RepositoryType>git</RepositoryType>
|
||||||
<PackageTags>file service web uploader html5 uploader breakpoint renewal</PackageTags>
|
<PackageTags>file service web uploader html5 uploader breakpoint renewal</PackageTags>
|
||||||
<Copyright>Copyright (c) 2020-$([System.DateTime]::Now.Year) Jackson.Bruce</Copyright>
|
<Copyright>Copyright (c) 2020-$([System.DateTime]::Now.Year) Jackson.Bruce</Copyright>
|
||||||
<Version>1.0.0-beta.1</Version>
|
<Version>1.0.2-beta</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(TargetFramework)|$(Platform)'=='netstandard2.0|AnyCPU'">
|
<PropertyGroup Condition="'$(TargetFramework)|$(Platform)'=='netstandard2.0|AnyCPU'">
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ namespace Ufangx.FileServices.Middlewares
|
|||||||
}
|
}
|
||||||
protected override async Task Handler(HttpContext context)
|
protected override async Task Handler(HttpContext context)
|
||||||
{
|
{
|
||||||
string key = context.Request.Form["key"];
|
string key = context.Request.Query["key"];
|
||||||
var service= context.RequestServices.GetRequiredService<IResumableService>();
|
var service= context.RequestServices.GetRequiredService<IResumableService>();
|
||||||
await WriteJsonAsync(context, await service.DeleteBlobs(key));
|
await WriteJsonAsync(context, await service.DeleteBlobs(key));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,9 @@ using System.Threading.Tasks;
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using TestWeb.Models;
|
using TestWeb.Models;
|
||||||
|
using Microsoft.AspNetCore.Authentication;
|
||||||
|
using Microsoft.AspNetCore.Authentication.Cookies;
|
||||||
|
using System.Security.Claims;
|
||||||
|
|
||||||
namespace TestWeb.Controllers
|
namespace TestWeb.Controllers
|
||||||
{
|
{
|
||||||
@@ -18,8 +21,16 @@ namespace TestWeb.Controllers
|
|||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IActionResult Index()
|
public async Task<IActionResult> Index()
|
||||||
{
|
{
|
||||||
|
if (!User.Identity.IsAuthenticated) {
|
||||||
|
var identity = new ClaimsIdentity("form");
|
||||||
|
identity.AddClaims(new Claim[] {
|
||||||
|
new Claim(ClaimTypes.Sid,"uk"),
|
||||||
|
new Claim(ClaimTypes.Name,"admin")
|
||||||
|
});
|
||||||
|
await HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme,new ClaimsPrincipal(identity),new AuthenticationProperties() { IsPersistent=true });
|
||||||
|
}
|
||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,9 +27,12 @@ namespace TestWeb
|
|||||||
// This method gets called by the runtime. Use this method to add services to the container.
|
// This method gets called by the runtime. Use this method to add services to the container.
|
||||||
public void ConfigureServices(IServiceCollection services)
|
public void ConfigureServices(IServiceCollection services)
|
||||||
{
|
{
|
||||||
|
services.AddDistributedMemoryCache();
|
||||||
|
services.AddAuthentication().AddCookie();
|
||||||
services.AddHttpContextAccessor();
|
services.AddHttpContextAccessor();
|
||||||
services.AddFileServices(opt => {
|
services.AddFileServices(opt =>
|
||||||
opt.DefaultScheme = "documents";//Ĭ<><C4AC><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD><C4B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
{
|
||||||
|
opt.DefaultScheme = "Document";//Ĭ<><C4AC><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD><C4B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
opt.AddAuthenticationScheme(CookieAuthenticationDefaults.AuthenticationScheme);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֤<EFBFBD><D6A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
opt.AddAuthenticationScheme(CookieAuthenticationDefaults.AuthenticationScheme);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֤<EFBFBD><D6A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
//<2F>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
//<2F>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
opt.RuleOptions = new Ufangx.FileServices.Models.FileNameRuleOptions()
|
opt.RuleOptions = new Ufangx.FileServices.Models.FileNameRuleOptions()
|
||||||
@@ -41,27 +44,34 @@ namespace TestWeb
|
|||||||
|
|
||||||
})
|
})
|
||||||
//<2F><>Ƭ<EFBFBD><C6AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
//<2F><>Ƭ<EFBFBD><C6AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
.AddScheme("pictures", opt => {
|
.AddScheme("pictures", opt =>
|
||||||
|
{
|
||||||
opt.StoreDirectory = "wwwroot/pictures";//ͼƬ<CDBC>洢<EFBFBD><E6B4A2>Ŀ¼
|
opt.StoreDirectory = "wwwroot/pictures";//ͼƬ<CDBC>洢<EFBFBD><E6B4A2>Ŀ¼
|
||||||
opt.SupportExtensions = new string[] { ".jpg", ".png" };//֧<>ֵ<EFBFBD><D6B5><EFBFBD>չ<EFBFBD><D5B9>
|
opt.SupportExtensions = new string[] { ".jpg", ".png" };//֧<>ֵ<EFBFBD><D6B5><EFBFBD>չ<EFBFBD><D5B9>
|
||||||
opt.HandlerType = null;//<2F>ϴ<EFBFBD><CFB4>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͣ<EFBFBD><CDA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͱ<EFBFBD><CDB1><EFBFBD>ʵ<EFBFBD><CAB5>IFileHandler<65>ӿ<EFBFBD>
|
opt.HandlerType = null;//<2F>ϴ<EFBFBD><CFB4>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͣ<EFBFBD><CDA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͱ<EFBFBD><CDB1><EFBFBD>ʵ<EFBFBD><CAB5>IFileHandler<65>ӿ<EFBFBD>
|
||||||
opt.LimitedSize = 1024 * 1024 * 4;//<2F>ļ<EFBFBD><C4BC><EFBFBD>С<EFBFBD><D0A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD>ֽ<EFBFBD>Ϊ<EFBFBD><CEAA>λ
|
opt.LimitedSize = 1024 * 1024 * 4;//<2F>ļ<EFBFBD><C4BC><EFBFBD>С<EFBFBD><D0A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD>ֽ<EFBFBD>Ϊ<EFBFBD><CEAA>λ
|
||||||
})
|
})
|
||||||
.AddScheme("documents",opt => opt.StoreDirectory = "wwwroot/documents")//<2F>ĵ<EFBFBD><C4B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
.AddScheme("Document", opt => opt.StoreDirectory = "wwwroot/documents")//<2F>ĵ<EFBFBD><C4B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
//.AddScheme<VideoService>(name:"videos",storeDirectory:"",supportExtensions:new string[] { },LimitedSize:1024*1024*500)//<2F><>Ƶ<EFBFBD><C6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
//.AddScheme<VideoService>(name:"videos",storeDirectory:"",supportExtensions:new string[] { },LimitedSize:1024*1024*500)//<2F><>Ƶ<EFBFBD><C6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
//.AddLocalServices(o => o.StorageRootDir = hostEnvironment.ContentRootPath)//<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>ϵͳ<CFB5><CDB3><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>ڱ<EFBFBD><DAB1><EFBFBD>
|
.AddLocalServices(o => o.StorageRootDir = hostEnvironment.ContentRootPath);//<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>ϵͳ<CFB5><CDB3><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>ڱ<EFBFBD><DAB1><EFBFBD>
|
||||||
//<2F><>ţ<EFBFBD>洢<EFBFBD><E6B4A2><EFBFBD><EFBFBD>
|
//<2F><>ţ<EFBFBD>洢<EFBFBD><E6B4A2><EFBFBD><EFBFBD>
|
||||||
.AddQiniuFileService(opt => {
|
//.AddQiniuFileService(opt => {
|
||||||
opt.AccessKey = "";//
|
// opt.AccessKey = "";//
|
||||||
opt.SecretKey = "";
|
// opt.SecretKey = "";
|
||||||
opt.BasePath = "";
|
// opt.BasePath = "";
|
||||||
opt.Bucket = "";
|
// opt.Bucket = "";
|
||||||
opt.Domain = "";
|
// opt.Domain = "";
|
||||||
opt.ChunkUnit = Qiniu.Storage.ChunkUnit.U1024K;
|
// opt.ChunkUnit = Qiniu.Storage.ChunkUnit.U1024K;
|
||||||
opt.Zone = "ZoneCnEast";
|
// opt.Zone = "ZoneCnEast";
|
||||||
|
|
||||||
|
//});
|
||||||
|
services.AddCors(options =>
|
||||||
|
{
|
||||||
|
options.AddPolicy("cors", builder =>
|
||||||
|
{
|
||||||
|
builder.AllowCredentials().AllowAnyMethod().AllowAnyHeader().WithOrigins("http://localhost:9000");
|
||||||
});
|
});
|
||||||
|
});
|
||||||
services.AddControllersWithViews();
|
services.AddControllersWithViews();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,6 +91,7 @@ namespace TestWeb
|
|||||||
app.UseHttpsRedirection();
|
app.UseHttpsRedirection();
|
||||||
app.UseStaticFiles();
|
app.UseStaticFiles();
|
||||||
|
|
||||||
|
app.UseCors("cors");
|
||||||
app.UseRouting();
|
app.UseRouting();
|
||||||
|
|
||||||
app.UseAuthorization();
|
app.UseAuthorization();
|
||||||
|
|||||||
@@ -12,7 +12,14 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.10.8" />
|
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.10.8" />
|
||||||
<PackageReference Include="Qiniu.FileService" Version="1.0.0-beta.1" />
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\FileService\FileServices.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="wwwroot\documents\" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user