init
This commit is contained in:
commit
e124a47765
19374 changed files with 9806149 additions and 0 deletions
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;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue