Beispiel #1
0
        public IHttpActionResult GetArchiveContent([FromUri] Guid archiveId)
        {
            try
            {
                //  if (activityId.IsNullOrEmpty())
                //      return BadRequest("Invalid activity id received.");
                var content = _activitiesService.GetArchiveContent(archiveId);
                var toBytes = Encoding.Unicode.GetBytes(content);

                var stream = new MemoryStream(toBytes);

                var result = new HttpResponseMessage(HttpStatusCode.OK)
                {
                    Content = new StreamContent(stream)
                };
                result.Content.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("attachment")
                {
                    FileName = archiveId + ".txt"
                };
                result.Content.Headers.ContentType = new MediaTypeHeaderValue("text/plain");

                var response = ResponseMessage(result);
                return(response);
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }