Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix content length of file parameter #769

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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