Compare commits
3 Commits
85f47330bd
...
69cd60000e
Author | SHA1 | Date |
---|---|---|
ArgonarioD | 69cd60000e | |
ArgonarioD | f21281d9f9 | |
ArgonarioD | b800161895 |
|
@ -19,9 +19,10 @@ public class FileController : ControllerBase {
|
||||||
public async Task<IActionResult> GetFileStatus(string fileId) {
|
public async Task<IActionResult> GetFileStatus(string fileId) {
|
||||||
try {
|
try {
|
||||||
var metadata = await _knowledgeFileHandler.GetFileMetadata(fileId);
|
var metadata = await _knowledgeFileHandler.GetFileMetadata(fileId);
|
||||||
var existingRanges = await _knowledgeFileHandler.GetAllPartFileRanges(fileId);
|
var existingRanges = (await _knowledgeFileHandler.GetAllPartFileRanges(fileId))
|
||||||
|
.Select((range, _) => $"{range.Item1}-{range.Item2}");
|
||||||
|
|
||||||
return Ok(new FileStatus(metadata.IsCompleted, metadata.Md5, metadata.Size, existingRanges));
|
return Ok(new FileStatus(metadata.IsCompleted, metadata.Md5, metadata.Size, existingRanges.ToList()));
|
||||||
} catch (FileNotFoundException) {
|
} catch (FileNotFoundException) {
|
||||||
return NotFound();
|
return NotFound();
|
||||||
}
|
}
|
||||||
|
@ -83,5 +84,5 @@ internal record FileStatus(
|
||||||
bool IsCompleted,
|
bool IsCompleted,
|
||||||
string Md5,
|
string Md5,
|
||||||
ulong Size,
|
ulong Size,
|
||||||
List<Tuple<ulong, ulong>> ExistingRanges
|
List<string> ExistingRanges
|
||||||
);
|
);
|
|
@ -20,11 +20,11 @@ public class KnowledgeFileHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<string[]> GetAllPartFiles(string fileId) {
|
public async Task<string[]> GetAllPartFiles(string fileId) {
|
||||||
return Directory.GetFiles($"{FilePath}/{fileId}.part.*");
|
return Directory.GetFiles(FilePath, $"{fileId}.part.*");
|
||||||
}
|
}
|
||||||
|
|
||||||
public Tuple<ulong, ulong> ConvertPartFileNameToRange(string fileName) {
|
public Tuple<ulong, ulong> ConvertPartFileNameToRange(string fileName) {
|
||||||
var range = fileName.Split('.')[2].Split('-');
|
var range = fileName.Split('.').Last().Split('-');
|
||||||
return Tuple.Create(ulong.Parse(range[0]), ulong.Parse(range[1]));
|
return Tuple.Create(ulong.Parse(range[0]), ulong.Parse(range[1]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,7 +43,8 @@ public class KnowledgeFileHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task SaveFileSlice(string fileId, IFormFile file, ulong rangeStart, ulong rangeEnd) {
|
public async Task SaveFileSlice(string fileId, IFormFile file, ulong rangeStart, ulong rangeEnd) {
|
||||||
await file.CopyToAsync(File.Create(GetSliceFileName(fileId, rangeStart, rangeEnd)));
|
await using var fileStream = File.Create(GetSliceFileName(fileId, rangeStart, rangeEnd));
|
||||||
|
await file.CopyToAsync(fileStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <exception cref="InvalidDataException">缺失分片时抛出,其Message内容是缺失分片的Range</exception>
|
/// <exception cref="InvalidDataException">缺失分片时抛出,其Message内容是缺失分片的Range</exception>
|
||||||
|
|
|
@ -8,6 +8,7 @@ Directory.CreateDirectory("./files");
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
builder.WebHost.UseUrls("https://*:8081");
|
builder.WebHost.UseUrls("https://*:8081");
|
||||||
builder.WebHost.UseKestrel((context, options) => {
|
builder.WebHost.UseKestrel((context, options) => {
|
||||||
|
options.Limits.MaxRequestBodySize = 1073741824L;
|
||||||
options.ConfigureEndpointDefaults(listenOptions => {
|
options.ConfigureEndpointDefaults(listenOptions => {
|
||||||
listenOptions.Protocols = HttpProtocols.Http1AndHttp2AndHttp3;
|
listenOptions.Protocols = HttpProtocols.Http1AndHttp2AndHttp3;
|
||||||
listenOptions.UseHttps(builder.Configuration.GetSection(SslOptions.SectionName).Get<SslOptions>()!
|
listenOptions.UseHttps(builder.Configuration.GetSection(SslOptions.SectionName).Get<SslOptions>()!
|
||||||
|
|
|
@ -1,2 +1,4 @@
|
||||||
docker build -f .\AicsKnowledgeBase_file\Dockerfile -t auto/aics_file:latest .
|
docker build -f .\AicsKnowledgeBase_file\Dockerfile -t auto/aics_file:latest .
|
||||||
|
echo 'saving...'
|
||||||
|
docker save -o ..\docker\aics_file.tar auto/aics_file:latest
|
||||||
pause
|
pause
|
Loading…
Reference in New Issue