Skip to content

Commit 5ffc1f6

Browse files
committed
Merge pull request #769 from dgreenbean/feature/add_file_action_content_length
Fix content length of file parameter
2 parents 0ef81fd + 16f48c0 commit 5ffc1f6

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

RestSharp/IRestRequest.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,10 @@ public interface IRestRequest
158158
/// <param name="name">The parameter name to use in the request</param>
159159
/// <param name="writer">A function that writes directly to the stream. Should NOT close the stream.</param>
160160
/// <param name="fileName">The file name to use for the uploaded file</param>
161+
/// <param name="contentLength">The length (in bytes) of the file content.</param>
161162
/// <param name="contentType">The MIME type of the file to upload</param>
162163
/// <returns>This request</returns>
163-
IRestRequest AddFile(string name, Action<Stream> writer, string fileName, string contentType = null);
164+
IRestRequest AddFile(string name, Action<Stream> writer, string fileName, long contentLength, string contentType = null);
164165

165166
/// <summary>
166167
/// Add bytes to the Files collection as if it was a file of specific type

RestSharp/RestRequest.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,15 +172,17 @@ public IRestRequest AddFile(string name, byte[] bytes, string fileName, string c
172172
/// <param name="name">The parameter name to use in the request</param>
173173
/// <param name="writer">A function that writes directly to the stream. Should NOT close the stream.</param>
174174
/// <param name="fileName">The file name to use for the uploaded file</param>
175+
/// <param name="contentLength">The length (in bytes) of the file content.</param>
175176
/// <param name="contentType">The MIME type of the file to upload</param>
176177
/// <returns>This request</returns>
177-
public IRestRequest AddFile(string name, Action<Stream> writer, string fileName, string contentType = null)
178+
public IRestRequest AddFile(string name, Action<Stream> writer, string fileName, long contentLength, string contentType = null)
178179
{
179180
return this.AddFile(new FileParameter
180181
{
181182
Name = name,
182183
Writer = writer,
183184
FileName = fileName,
185+
ContentLength = contentLength,
184186
ContentType = contentType
185187
});
186188
}

0 commit comments

Comments
 (0)