init
This commit is contained in:
30
KretaWeb/Helpers/HttpResponseExtensions.cs
Normal file
30
KretaWeb/Helpers/HttpResponseExtensions.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Net.Mime;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
using Kreta.BusinessLogic.Classes;
|
||||
|
||||
namespace Kreta.Web.Helpers
|
||||
{
|
||||
public static class HttpResponseExtensions
|
||||
{
|
||||
public static HttpResponseMessage GetFileHttpResponse(byte[] content, string fileName)
|
||||
{
|
||||
var result = new HttpResponseMessage(HttpStatusCode.OK)
|
||||
{
|
||||
Content = new ByteArrayContent(content)
|
||||
};
|
||||
|
||||
result.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")
|
||||
{
|
||||
FileName = HttpUtility.UrlEncode(fileName.ToComparableString(), Encoding.UTF8)
|
||||
};
|
||||
|
||||
result.Content.Headers.ContentType = new MediaTypeHeaderValue(MediaTypeNames.Application.Octet);
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user