public Response <int> AddorUpdate(Person person)
 {
     return(_fileService.AddOrUpdate(person));
 }
        public async Task <ResponseResult <dynamic> > Upload([FromServices] IWebHostEnvironment environment)
        {
            var    data = new ResponseResult <dynamic>();
            string path = string.Empty;

            IFormFileCollection files = null;

            try
            {
                files = Request.Form.Files;
            }
            catch (Exception)
            {
                files = null;
            }

            if (files == null || !files.Any())
            {
                data.Message = nameof(BusinessCode.Image_Empty);
                data.Code    = BusinessCode.Image_Empty;
                return(data);
            }
            //格式限制


            string folderpath = Path.Combine(environment.WebRootPath, _uploadOptions.UploadFilePath);

            if (!System.IO.Directory.Exists(folderpath))
            {
                System.IO.Directory.CreateDirectory(folderpath);
            }

            if (files.Any(c => _uploadOptions.AllowedFileTypes?.Contains(c.ContentType.ToLower()) == true))
            {
                if (files.Sum(c => c.Length) <= _uploadOptions.UploadLimitSize)
                {
                    //foreach (var file in files)
                    var    file    = files.FirstOrDefault();
                    string strpath = Path.Combine(_uploadOptions.UploadFilePath, DateTime.Now.ToString("MMddHHmmss") + file.FileName);
                    path = Path.Combine(environment.WebRootPath, strpath);
                    string        md5Code = string.Empty;
                    UploadFileDto uploadFileDto;
                    int           uploadFileId = 0;
                    using (var stream = file.OpenReadStream())
                    {
                        md5Code       = GetFileMD5(stream);
                        uploadFileDto = await _uploadService.Get <UploadFileDto>(f => f.MD5Code == md5Code);

                        if (uploadFileDto == null)
                        {
                            using (var filestream = System.IO.File.Create(path))
                            {
                                await file.CopyToAsync(filestream);
                            }
                            uploadFileDto = new UploadFileDto
                            {
                                MD5Code   = md5Code,
                                RUrl      = strpath.Replace("\\", "/"),
                                Filename  = file.FileName,
                                Extention = Path.GetExtension(file.FileName).ToLower()
                            };

                            uploadFileId = (await _uploadService.AddOrUpdate <UploadFileDto, int>(uploadFileDto)).Id;
                        }
                        else
                        {
                            uploadFileId = uploadFileDto.Id;
                        }
                        strpath = UriCombine(Request.GetHostUri(), uploadFileDto.RUrl);
                        //strpath = uploadFileDto.RUrl;
                    }

                    data = new ResponseResult <dynamic>()
                    {
                        Data = new { url = strpath, id = uploadFileId }
                    };
                    return(data);
                }
                else
                {
                    data.Message = nameof(BusinessCode.Image_Size_Error);;
                    data.Code    = BusinessCode.Image_Size_Error;
                    return(data);
                }
            }
            else

            {
                data.Message = nameof(BusinessCode.Image_Type_Error);
                data.Code    = BusinessCode.Image_Type_Error;
                return(data);
            }
        }