Skip to content

Commit

Permalink
Adding required input of content length when adding a file using a wr…
Browse files Browse the repository at this point in the history
…iter action.
  • Loading branch information
dgreenberg-cimpress committed Nov 2, 2015
1 parent 0ef81fd commit 16f48c0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion RestSharp/IRestRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,10 @@ public interface IRestRequest
/// <param name="name">The parameter name to use in the request</param>
/// <param name="writer">A function that writes directly to the stream. Should NOT close the stream.</param>
/// <param name="fileName">The file name to use for the uploaded file</param>
/// <param name="contentLength">The length (in bytes) of the file content.</param>
/// <param name="contentType">The MIME type of the file to upload</param>
/// <returns>This request</returns>
IRestRequest AddFile(string name, Action<Stream> writer, string fileName, string contentType = null);
IRestRequest AddFile(string name, Action<Stream> writer, string fileName, long contentLength, string contentType = null);

/// <summary>
/// Add bytes to the Files collection as if it was a file of specific type
Expand Down
4 changes: 3 additions & 1 deletion RestSharp/RestRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,15 +172,17 @@ public IRestRequest AddFile(string name, byte[] bytes, string fileName, string c
/// <param name="name">The parameter name to use in the request</param>
/// <param name="writer">A function that writes directly to the stream. Should NOT close the stream.</param>
/// <param name="fileName">The file name to use for the uploaded file</param>
/// <param name="contentLength">The length (in bytes) of the file content.</param>
/// <param name="contentType">The MIME type of the file to upload</param>
/// <returns>This request</returns>
public IRestRequest AddFile(string name, Action<Stream> writer, string fileName, string contentType = null)
public IRestRequest AddFile(string name, Action<Stream> writer, string fileName, long contentLength, string contentType = null)
{
return this.AddFile(new FileParameter
{
Name = name,
Writer = writer,
FileName = fileName,
ContentLength = contentLength,
ContentType = contentType
});
}
Expand Down

0 comments on commit 16f48c0

Please sign in to comment.