File upload frontpage and download decryption

This commit is contained in:
2025-07-26 03:11:42 +08:00
parent 0486c0d0e5
commit f1867e7916
19 changed files with 1051 additions and 229 deletions

View File

@@ -44,6 +44,10 @@ public abstract class TusService
if (!allowed.HasPermission)
eventContext.FailRequest(HttpStatusCode.Forbidden);
}
var filePool = httpContext.Request.Headers["X-FilePool"].FirstOrDefault();
if (!string.IsNullOrEmpty(filePool) && !Guid.TryParse(filePool, out _))
eventContext.FailRequest(HttpStatusCode.BadRequest, "Invalid file pool id");
},
OnFileCompleteAsync = async eventContext =>
{
@@ -62,12 +66,17 @@ public abstract class TusService
var fileStream = await file.GetContentAsync(eventContext.CancellationToken);
var filePool = httpContext.Request.Headers["X-FilePool"].FirstOrDefault();
var encryptPassword = httpContext.Request.Headers["X-FilePass"].FirstOrDefault();
if (string.IsNullOrEmpty(filePool))
filePool = configuration["Storage:PreferredRemote"];
var fileService = services.GetRequiredService<FileService>();
var info = await fileService.ProcessNewFileAsync(
user,
file.Id,
filePool,
fileStream,
fileName,
contentType,
@@ -89,7 +98,7 @@ public abstract class TusService
if (gatewayUrl is not null)
eventContext.SetUploadUrl(new Uri(gatewayUrl + "/drive/tus/" + eventContext.FileId));
return Task.CompletedTask;
}
},
}
};
}