Renamed fileName back to filePath
This commit is contained in:
parent
2b892dfd66
commit
bd4f5f63b6
@ -118,21 +118,21 @@ namespace MontoyaTech.Rest.Net
|
|||||||
/// Sets the response content type to a file and writes the file content with name to the response.
|
/// Sets the response content type to a file and writes the file content with name to the response.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="response"></param>
|
/// <param name="response"></param>
|
||||||
/// <param name="fileName"></param>
|
/// <param name="filePath"></param>
|
||||||
/// <param name="content"></param>
|
/// <param name="content"></param>
|
||||||
/// <param name="mimeType"></param>
|
/// <param name="mimeType"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
/// <exception cref="ArgumentException"></exception>
|
/// <exception cref="ArgumentException"></exception>
|
||||||
public static HttpListenerResponse WithFile(this HttpListenerResponse response, string fileName, byte[] content, string mimeType = null)
|
public static HttpListenerResponse WithFile(this HttpListenerResponse response, string filePath, byte[] content, string mimeType = null)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(fileName))
|
if (string.IsNullOrWhiteSpace(filePath))
|
||||||
throw new ArgumentException("fileName must not be null or empty");
|
throw new ArgumentException("filePath must not be null or empty");
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(mimeType))
|
if (string.IsNullOrWhiteSpace(mimeType))
|
||||||
mimeType = Path.GetExtension(fileName).GetMimeType();
|
mimeType = Path.GetExtension(filePath).GetMimeType();
|
||||||
|
|
||||||
response.ContentType = mimeType;
|
response.ContentType = mimeType;
|
||||||
response.Headers.Add("Content-Deposition", $@"attachment; filename=""{Path.GetFileName(fileName)}""");
|
response.Headers.Add("Content-Deposition", $@"attachment; filename=""{Path.GetFileName(filePath)}""");
|
||||||
response.SendChunked = true;
|
response.SendChunked = true;
|
||||||
|
|
||||||
using (var responseStream = response.OutputStream)
|
using (var responseStream = response.OutputStream)
|
||||||
@ -173,21 +173,21 @@ namespace MontoyaTech.Rest.Net
|
|||||||
/// Sets the response content type to a file and writes the file content with name to the response.
|
/// Sets the response content type to a file and writes the file content with name to the response.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="response"></param>
|
/// <param name="response"></param>
|
||||||
/// <param name="fileName"></param>
|
/// <param name="filePath"></param>
|
||||||
/// <param name="content"></param>
|
/// <param name="content"></param>
|
||||||
/// <param name="mimeType"></param>
|
/// <param name="mimeType"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
/// <exception cref="ArgumentException"></exception>
|
/// <exception cref="ArgumentException"></exception>
|
||||||
public static HttpListenerResponse WithCompressedFile(this HttpListenerResponse response, string fileName, byte[] content, string mimeType = null)
|
public static HttpListenerResponse WithCompressedFile(this HttpListenerResponse response, string filePath, byte[] content, string mimeType = null)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(fileName))
|
if (string.IsNullOrWhiteSpace(filePath))
|
||||||
throw new ArgumentException("filePath must not be null or empty");
|
throw new ArgumentException("filePath must not be null or empty");
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(mimeType))
|
if (string.IsNullOrWhiteSpace(mimeType))
|
||||||
mimeType = Path.GetExtension(fileName).GetMimeType();
|
mimeType = Path.GetExtension(filePath).GetMimeType();
|
||||||
|
|
||||||
response.ContentType = mimeType;
|
response.ContentType = mimeType;
|
||||||
response.Headers.Add("Content-Deposition", $@"attachment; filename=""{Path.GetFileName(fileName)}""");
|
response.Headers.Add("Content-Deposition", $@"attachment; filename=""{Path.GetFileName(filePath)}""");
|
||||||
response.Headers.Add("Content-Encoding", "gzip");
|
response.Headers.Add("Content-Encoding", "gzip");
|
||||||
response.SendChunked = true;
|
response.SendChunked = true;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user