From 16f48c04ecd3caff30c2b42d7e27d1b06efb95a2 Mon Sep 17 00:00:00 2001 From: David Greenberg Date: Thu, 22 Oct 2015 14:42:08 -0400 Subject: [PATCH] Adding required input of content length when adding a file using a writer action. --- RestSharp/IRestRequest.cs | 3 ++- RestSharp/RestRequest.cs | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/RestSharp/IRestRequest.cs b/RestSharp/IRestRequest.cs index 2d0b0c88d..fcf57fe2d 100644 --- a/RestSharp/IRestRequest.cs +++ b/RestSharp/IRestRequest.cs @@ -158,9 +158,10 @@ public interface IRestRequest /// The parameter name to use in the request /// A function that writes directly to the stream. Should NOT close the stream. /// The file name to use for the uploaded file + /// The length (in bytes) of the file content. /// The MIME type of the file to upload /// This request - IRestRequest AddFile(string name, Action writer, string fileName, string contentType = null); + IRestRequest AddFile(string name, Action writer, string fileName, long contentLength, string contentType = null); /// /// Add bytes to the Files collection as if it was a file of specific type diff --git a/RestSharp/RestRequest.cs b/RestSharp/RestRequest.cs index f7cc6b2b7..cb227f7a8 100644 --- a/RestSharp/RestRequest.cs +++ b/RestSharp/RestRequest.cs @@ -172,15 +172,17 @@ public IRestRequest AddFile(string name, byte[] bytes, string fileName, string c /// The parameter name to use in the request /// A function that writes directly to the stream. Should NOT close the stream. /// The file name to use for the uploaded file + /// The length (in bytes) of the file content. /// The MIME type of the file to upload /// This request - public IRestRequest AddFile(string name, Action writer, string fileName, string contentType = null) + public IRestRequest AddFile(string name, Action writer, string fileName, long contentLength, string contentType = null) { return this.AddFile(new FileParameter { Name = name, Writer = writer, FileName = fileName, + ContentLength = contentLength, ContentType = contentType }); }