Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit 7dd879d

Browse files
committed
Make field in UploadFile overridable
1 parent ff9a2f0 commit 7dd879d

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/ServiceStack.Text/HttpUtils.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -968,7 +968,7 @@ public static Task<HttpWebResponse> GetResponseAsync(this HttpWebRequest request
968968
}
969969

970970
public static void UploadFile(this WebRequest webRequest, Stream fileStream, string fileName, string mimeType,
971-
string accept = null, Action<HttpWebRequest> requestFilter = null, string method = "POST")
971+
string accept = null, Action<HttpWebRequest> requestFilter = null, string method = "POST", string field = "file")
972972
{
973973
var httpReq = (HttpWebRequest)webRequest;
974974
httpReq.Method = method;
@@ -984,10 +984,8 @@ public static void UploadFile(this WebRequest webRequest, Stream fileStream, str
984984

985985
var boundarybytes = ("\r\n--" + boundary + "--\r\n").ToAsciiBytes();
986986

987-
var headerTemplate = "\r\n--" + boundary +
988-
"\r\nContent-Disposition: form-data; name=\"file\"; filename=\"{0}\"\r\nContent-Type: {1}\r\n\r\n";
989-
990-
var header = string.Format(headerTemplate, fileName, mimeType);
987+
var header = "\r\n--" + boundary +
988+
$"\r\nContent-Disposition: form-data; name=\"{field}\"; filename=\"{fileName}\"\r\nContent-Type: {mimeType}\r\n\r\n";
991989

992990
var headerbytes = header.ToAsciiBytes();
993991

0 commit comments

Comments
 (0)