public async Task <IActionResult> GetPhoto(Guid id) { var photoEntity = await photosRepository.GetPhotoMetaAsync(id); if (photoEntity == null) { return(NotFound()); } var photo = mapper.Map <Photo>(photoEntity); var model = new GetPhotoModel(photo); return(View(model)); }
public IActionResult PostGetPhoto([FromBody] GetPhotoModel getPhotoModel) { var photoDataBase = PhotoManager.Instance.GetPhotoDataById(getPhotoModel.PhotoId); if (photoDataBase == null) { return(BadRequest(new { message = "图片ID错误Id=" + getPhotoModel.PhotoId })); } var bytes = PhotoManager.Instance.GetPhotoBtyes(photoDataBase, getPhotoModel.BeBig); if (bytes == null && bytes.Length <= 0) { return(BadRequest(new { message = "未请求到正确的数据 ,Id=" + getPhotoModel.PhotoId })); } string s = Convert.ToBase64String(bytes); // new FileContentResult(bytes, "image/jpeg"); var upUser = UserInfoManager.Instance.GetUserInfo(photoDataBase.UploadUserId); string photoUserName = upUser != null?upUser.NickName:"未知"; return(Ok(new { message = "ok", data = new { photoDataBase.PhotoId, photoDataBase.PhotoName, photoDataBase.CreatTime, photoUserName, photoData = s } })); }