コード例 #1
0
        public async Task <List <string> > UploadImageStream()
        {
            var m = new List <string>();

            if (HttpContext.Request.Form.Files.Any())
            {
                foreach (var file in HttpContext.Request.Form.Files)
                {
                    var fileName = $"{Guid.NewGuid()}.jpg";
                    var path     = Path.Combine(_env.WebRootPath, $"mms/{fileName}");
                    //resize
                    await ImageSize.ResizeImageToFile(path, file);

                    //todo no resize
                    //await using var stream = new FileStream(path, FileMode.Create);
                    //await file.CopyToAsync(stream);
                    m.Add($"{Constants.Domain}/mms/{fileName}");
                }
            }
            return(m);
        }