使用AppSelfHostBase的自托管服务堆栈主机具有一种服务方法:
public object Any(UploadImageRequest request)
{
// Need to make sure the file is not too large!
}
[Route("/UploadImage")]
public class UploadImageRequest : IRequiresRequestStream
{
public Stream RequestStream { get; set; }
}
答案 0 :(得分:2)
我实际上找到了一种可能的方法:
public object Any(UploadImageRequest request)
{
if (Request.ContentLength > 10 * 1024 * 1024)
{
return new HttpResult($"Image too large!", HttpStatusCode.RequestEntityTooLarge);
}
...
}