All Downloads are FREE. Search and download functionalities are using the official Maven repository.

aspnetcore.3.0.Formatters.InputFormatterStream.mustache Maven / Gradle / Ivy

There is a newer version: 7.7.0
Show newest version
{{>partial_header}}
using System;
using System.IO;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc.Formatters;

namespace {{packageName}}.Formatters
{
    /// 
    public class InputFormatterStream : InputFormatter
    {
        /// 
        public InputFormatterStream()
        {
            SupportedMediaTypes.Add("application/octet-stream");
            SupportedMediaTypes.Add("image/jpeg");
        }

        /// 
        public override Task ReadRequestBodyAsync(InputFormatterContext context)
        {
            return InputFormatterResult.SuccessAsync(context.HttpContext.Request.Body);
        }

        /// 
        protected override bool CanReadType(Type type)
        {
            if (type == typeof(Stream))
            {
                return true;
            }

            return false;
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy