private List <TemporaryFileUpdatedResult> UploadFile(HttpContext context)
        {
            bool saveAsGrayscale = false;

            bool.TryParse(context.Request.Query["grayscale"], out saveAsGrayscale);

            var files  = context.Request.Form.Files;
            var result = new List <TemporaryFileUpdatedResult>();

            try
            {
                IFormFile file = null;
                for (var i = 0; i < files.Count; i++)
                {
                    file = files[i];

                    var fileEntry  = new TemporaryFileUploadDTO(file.FileName, file.ContentType, file.OpenReadStream(), saveAsGrayscale);
                    var resultItem = fileEntry.SaveFile(BaseTemporaryStorage);

                    result.Add(resultItem);
                }
            }
            catch (Exception)
            {
                throw;
            }

            return(result);
        }
示例#2
0
        public List <TemporaryFileUpdatedResult> ProcessRequest(HttpContext context)
        {
            if (context.Request.Method == "PUT")
            {
                return(null);
            }


            var files  = context.Request.Form.Files;
            var result = new List <TemporaryFileUpdatedResult>();

            try
            {
                IFormFile file = null;
                for (var i = 0; i < files.Count; i++)
                {
                    file = files[i];
                    var fileEntry  = new TemporaryFileUploadDTO(file);
                    var resultItem = fileEntry.SaveFile(BaseTemporaryStorage);

                    result.Add(resultItem);
                }
            }
            catch (Exception)
            {
                throw;
            }

            return(result);
        }