private string TryGetFileName(InputFormatterContext context)
        {
            var httpContextRequest = context.HttpContext.Request;

            if (!httpContextRequest.Headers.ContainsKey(HeaderNames.ContentDisposition))
            {
                return(null);
            }

            var stringValues             = httpContextRequest.Headers[HeaderNames.ContentDisposition];
            var contentDispositionString = stringValues.FirstOrDefault();
            var fileName = HeaderUtilityHelper.TryGetContentDispositionFileName(contentDispositionString);

            return(fileName);
        }
예제 #2
0
        public async Task <IActionResult> FindEntryMedia(Guid entryId,
                                                         [FromHeader(Name = "If-Match")] string ifMatch,
                                                         [FromHeader(Name = "Content-Disposition")] string contentDisposition)
        {
            if (string.IsNullOrWhiteSpace(ifMatch))
            {
                return(NotFound());
            }

            ifMatch = ifMatch.Replace("\"", string.Empty);
            string     fileName = HeaderUtilityHelper.TryGetContentDispositionFileName(contentDisposition);
            EntryMedia result   = string.IsNullOrWhiteSpace(fileName)
                ? await _mediaSearchStrategy.Find(entryId, ifMatch)
                : await _mediaSearchStrategy.Find(entryId, ifMatch, fileName);


            if (result == null)
            {
                return(NotFound());
            }

            return(NoContent());
        }