예제 #1
0
        public async Task <IActionResult> GetAvatar(string userid, string timespan = null)
        {
            AvatarUrlResult Result = await _mediator.Send(new GetAvatarQuery(userid));

            if (Result.State != OperationState.Success)
            {
                if (Result.ErrorContent.ErrorType == ErrorOrigin.Client)
                {
                    return(BadRequest(Result));
                }
                return(StatusCode((int)HttpStatusCode.InternalServerError));
            }

            // Do not close the stream, MVC will handle it
            var stream = System.IO.File.OpenRead(Result.Url);

            return(new FileStreamResult(stream, "image/png"));
        }
예제 #2
0
        public async Task <IActionResult> GetSmallThumb(string fileid)
        {
            AvatarUrlResult Result = await _mediator.Send(new GetThumbnailQuery(ThumbnailSize.Small, fileid));

            if (Result.State != OperationState.Success)
            {
                if (Result.ErrorContent.ErrorType == ErrorOrigin.Client)
                {
                    return(BadRequest(Result));
                }
                return(StatusCode((int)HttpStatusCode.InternalServerError));
            }

            // Do not close the stream, MVC will handle it
            var stream = System.IO.File.OpenRead(Result.Url);

            return(File(stream, "image/png"));
        }