🐛 Trying to fix upload offset not found in frontend
This commit is contained in:
@@ -174,6 +174,7 @@ function customRequest({
|
||||
'content-type': file.type ?? 'application/octet-stream',
|
||||
},
|
||||
headers: {
|
||||
'X-DirectUpload': 'true',
|
||||
...requestHeaders,
|
||||
...headers,
|
||||
},
|
||||
|
@@ -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);
|
||||
|
@@ -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
|
||||
{
|
||||
|
@@ -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));
|
||||
|
@@ -2,6 +2,14 @@ using DysonNetwork.Gateway.Startup;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
builder.Host.UseContentRoot(Directory.GetCurrentDirectory());
|
||||
builder.WebHost.ConfigureKestrel(options =>
|
||||
{
|
||||
options.Limits.MaxRequestBodySize = long.MaxValue;
|
||||
options.Limits.KeepAliveTimeout = TimeSpan.FromMinutes(2);
|
||||
options.Limits.RequestHeadersTimeout = TimeSpan.FromSeconds(30);
|
||||
});
|
||||
|
||||
// Add services to the container.
|
||||
builder.Services.AddGateway(builder.Configuration);
|
||||
builder.Services.AddControllers();
|
||||
@@ -12,7 +20,7 @@ app.UseRequestTimeouts();
|
||||
app.UseCors(opts =>
|
||||
opts.SetIsOriginAllowed(_ => true)
|
||||
.WithExposedHeaders("*")
|
||||
.WithHeaders()
|
||||
.WithHeaders("*")
|
||||
.AllowCredentials()
|
||||
.AllowAnyHeader()
|
||||
.AllowAnyMethod()
|
||||
|
@@ -25,7 +25,7 @@ public static class ApplicationConfiguration
|
||||
app.UseCors(opts =>
|
||||
opts.SetIsOriginAllowed(_ => true)
|
||||
.WithExposedHeaders("*")
|
||||
.WithHeaders()
|
||||
.WithHeaders("*")
|
||||
.AllowCredentials()
|
||||
.AllowAnyHeader()
|
||||
.AllowAnyMethod()
|
||||
|
@@ -20,7 +20,7 @@ public static class ApplicationConfiguration
|
||||
app.UseCors(opts =>
|
||||
opts.SetIsOriginAllowed(_ => true)
|
||||
.WithExposedHeaders("*")
|
||||
.WithHeaders()
|
||||
.WithHeaders("*")
|
||||
.AllowCredentials()
|
||||
.AllowAnyHeader()
|
||||
.AllowAnyMethod()
|
||||
|
@@ -10,12 +10,16 @@ namespace DysonNetwork.Shared.Http;
|
||||
|
||||
public static class KestrelConfiguration
|
||||
{
|
||||
public static WebApplicationBuilder ConfigureAppKestrel(this WebApplicationBuilder builder, IConfiguration configuration)
|
||||
public static WebApplicationBuilder ConfigureAppKestrel(
|
||||
this WebApplicationBuilder builder,
|
||||
IConfiguration configuration,
|
||||
long maxRequestBodySize = 50 * 1024 * 1024
|
||||
)
|
||||
{
|
||||
builder.Host.UseContentRoot(Directory.GetCurrentDirectory());
|
||||
builder.WebHost.ConfigureKestrel(options =>
|
||||
{
|
||||
options.Limits.MaxRequestBodySize = 50 * 1024 * 1024;
|
||||
options.Limits.MaxRequestBodySize = maxRequestBodySize;
|
||||
options.Limits.KeepAliveTimeout = TimeSpan.FromMinutes(2);
|
||||
options.Limits.RequestHeadersTimeout = TimeSpan.FromSeconds(30);
|
||||
|
||||
@@ -28,10 +32,7 @@ public static class KestrelConfiguration
|
||||
// Load PEM cert and key manually
|
||||
var certificate = X509Certificate2.CreateFromPemFile(certPath, keyPath);
|
||||
// Now pass the full cert
|
||||
options.ListenAnyIP(5001, listenOptions =>
|
||||
{
|
||||
listenOptions.UseHttps(certificate);
|
||||
});
|
||||
options.ListenAnyIP(5001, listenOptions => { listenOptions.UseHttps(certificate); });
|
||||
|
||||
// Optional: HTTP fallback
|
||||
options.ListenAnyIP(8080);
|
||||
|
Reference in New Issue
Block a user