improvements to .NET MAUI file upload based on #3674 (credit @thabaum)
This commit is contained in:
parent
d9beb4b660
commit
d57d7ec4d8
|
@ -20,6 +20,7 @@ using SixLabors.ImageSharp;
|
||||||
using SixLabors.ImageSharp.Processing;
|
using SixLabors.ImageSharp.Processing;
|
||||||
using SixLabors.ImageSharp.Formats.Png;
|
using SixLabors.ImageSharp.Formats.Png;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
|
using Microsoft.AspNetCore.Cors;
|
||||||
|
|
||||||
// ReSharper disable StringIndexOfIsCultureSpecific.1
|
// ReSharper disable StringIndexOfIsCultureSpecific.1
|
||||||
|
|
||||||
|
@ -358,6 +359,7 @@ namespace Oqtane.Controllers
|
||||||
}
|
}
|
||||||
|
|
||||||
// POST api/<controller>/upload
|
// POST api/<controller>/upload
|
||||||
|
[EnableCors(Constants.MauiCorsPolicy)]
|
||||||
[HttpPost("upload")]
|
[HttpPost("upload")]
|
||||||
public async Task UploadFile(string folder, IFormFile formfile)
|
public async Task UploadFile(string folder, IFormFile formfile)
|
||||||
{
|
{
|
||||||
|
|
|
@ -133,7 +133,7 @@ namespace Oqtane
|
||||||
|
|
||||||
services.AddCors(options =>
|
services.AddCors(options =>
|
||||||
{
|
{
|
||||||
options.AddPolicy(Constants.MauiUserAgent,
|
options.AddPolicy(Constants.MauiCorsPolicy,
|
||||||
policy =>
|
policy =>
|
||||||
{
|
{
|
||||||
policy.WithOrigins("https://0.0.0.0", "http://0.0.0.0", "app://0.0.0.0")
|
policy.WithOrigins("https://0.0.0.0", "http://0.0.0.0", "app://0.0.0.0")
|
||||||
|
@ -186,11 +186,11 @@ namespace Oqtane
|
||||||
|
|
||||||
app.UseHttpsRedirection();
|
app.UseHttpsRedirection();
|
||||||
app.UseStaticFiles();
|
app.UseStaticFiles();
|
||||||
app.UseCors(Constants.MauiUserAgent);
|
|
||||||
app.UseTenantResolution();
|
app.UseTenantResolution();
|
||||||
app.UseJwtAuthorization();
|
app.UseJwtAuthorization();
|
||||||
app.UseBlazorFrameworkFiles();
|
app.UseBlazorFrameworkFiles();
|
||||||
app.UseRouting();
|
app.UseRouting();
|
||||||
|
app.UseCors();
|
||||||
app.UseAuthentication();
|
app.UseAuthentication();
|
||||||
app.UseAuthorization();
|
app.UseAuthorization();
|
||||||
|
|
||||||
|
|
|
@ -77,6 +77,7 @@ namespace Oqtane.Shared
|
||||||
|
|
||||||
public static readonly string MauiUserAgent = "MAUI";
|
public static readonly string MauiUserAgent = "MAUI";
|
||||||
public static readonly string MauiAliasPath = "Alias-Path";
|
public static readonly string MauiAliasPath = "Alias-Path";
|
||||||
|
public const string MauiCorsPolicy = "MauiCorsPolicy"; // must be a constant to be used with an attribute
|
||||||
|
|
||||||
public static readonly string VisitorCookiePrefix = "APP_VISITOR_";
|
public static readonly string VisitorCookiePrefix = "APP_VISITOR_";
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user