Beispiel #1
0
        public HttpResponseMessage GetFile(Guid id, int version)
        {
            HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK);
            var material = _read.GetMaterialNameWithId(id, version);
            var fileName = material.UploadId;
            var bytes    = _repository.GetMaterialByte(fileName);
            var name     = material.MaterialName;

            response.Content = new ByteArrayContent(bytes);
            response.Content.Headers.ContentLength               = bytes.LongLength;
            response.Content.Headers.ContentDisposition          = new ContentDispositionHeaderValue("attachment");
            response.Content.Headers.ContentDisposition.FileName = name;
            response.Content.Headers.ContentType = new MediaTypeHeaderValue(MimeMapping.GetMimeMapping(name));
            return(response);
        }