コード例 #1
0
        public async Task <HttpResponseMessage> Get(Guid fileId, [FromServices] GetFileHandler fh)
        {
            HttpResponseMessage result = new HttpResponseMessage(HttpStatusCode.OK);

            var(stream, file) = await fh.Get(fileId);

            result.Content = new StreamContent(stream);
            result.Content.Headers.ContentType        = new MediaTypeHeaderValue(file.ContentType);
            result.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")
            {
                FileName = file.FileName
            };
            return(result);
        }
コード例 #2
0
        public async Task <IActionResult> Get(Guid fileId, [FromServices] GetFileHandler fh)
        {
            var(stream, file) = await fh.Get(fileId);

            return(File(stream, file.ContentType, file.FileName));
        }