This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Linq; | |
namespace Web.Infrastructure | |
{ | |
public static class RequestHelpers | |
{ | |
public static string GetBoundary(string contentType) | |
{ | |
var elements = contentType.Split(' '); | |
var element = elements.First(e => e.StartsWith("boundary=")); | |
var boundary = element.Substring("boundary=".Length); | |
if (boundary.Length >= 2 && boundary[0] == '"' && boundary[^1] == '"') | |
boundary = boundary[1..^1]; | |
return boundary; | |
} | |
public static bool IsMultipartContentType(string contentType) => !string.IsNullOrEmpty(contentType) && contentType.IndexOf("multipart/", StringComparison.OrdinalIgnoreCase) >= 0; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment