🐛 Trying to fix upload offset not found in frontend

This commit is contained in:
2025-07-27 14:25:45 +08:00
parent f74b1cf46a
commit 4a0117906a
8 changed files with 35 additions and 13 deletions

View File

@@ -174,6 +174,7 @@ function customRequest({
'content-type': file.type ?? 'application/octet-stream',
},
headers: {
'X-DirectUpload': 'true',
...requestHeaders,
...headers,
},

View File

@@ -11,7 +11,7 @@ using tusdotnet.Stores;
var builder = WebApplication.CreateBuilder(args);
// Configure Kestrel and server options
builder.ConfigureAppKestrel(builder.Configuration);
builder.ConfigureAppKestrel(builder.Configuration, maxRequestBodySize: long.MaxValue);
// Add application services
builder.Services.AddRegistryService(builder.Configuration);

View File

@@ -19,6 +19,15 @@ public static class ApplicationBuilderExtensions
app.UseAuthorization();
app.MapControllers();
app.UseCors(opts =>
opts.SetIsOriginAllowed(_ => true)
.WithExposedHeaders("*")
.WithHeaders("*")
.AllowCredentials()
.AllowAnyHeader()
.AllowAnyMethod()
);
app.UseDefaultFiles();
app.UseStaticFiles(new StaticFileOptions
{

View File

@@ -228,6 +228,9 @@ public abstract class TusService
},
OnCreateCompleteAsync = eventContext =>
{
var directUpload = eventContext.HttpContext.Request.Headers["X-DirectUpload"].FirstOrDefault();
if (!string.IsNullOrEmpty(directUpload)) return Task.CompletedTask;
var gatewayUrl = configuration["GatewayUrl"];
if (gatewayUrl is not null)
eventContext.SetUploadUrl(new Uri(gatewayUrl + "/drive/tus/" + eventContext.FileId));