Skip to content

Commit d3507c9

Browse files
author
Michael Hallett
committed
Merge branch 'petrce-master'
2 parents 75ddf06 + 17764dc commit d3507c9

File tree

4 files changed

+14
-34
lines changed

4 files changed

+14
-34
lines changed

.nuget/RestSharp.Build.dll

0 Bytes
Binary file not shown.

RestSharp/Http.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ private void AddSharedHeaderActions()
240240
#endif
241241

242242
#if FRAMEWORK
243-
restrictedHeaderActions.Add("Range", (r, v) => { AddRange(r, v); });
243+
restrictedHeaderActions.Add("Range", AddRange);
244244
#endif
245245
}
246246

RestSharp/IRestRequest.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,27 +136,29 @@ public interface IRestRequest
136136
/// </summary>
137137
/// <param name="name">The parameter name to use in the request</param>
138138
/// <param name="path">Full path to file to upload</param>
139+
/// <param name="contentType">The MIME type of the file to upload</param>
139140
/// <returns>This request</returns>
140-
IRestRequest AddFile(string name, string path);
141+
IRestRequest AddFile(string name, string path, string contentType = null);
141142

142143
/// <summary>
143-
/// Adds the bytes to the Files collection with the specified file name
144+
/// Adds the bytes to the Files collection with the specified file name and content type
144145
/// </summary>
145146
/// <param name="name">The parameter name to use in the request</param>
146147
/// <param name="bytes">The file data</param>
147148
/// <param name="fileName">The file name to use for the uploaded file</param>
149+
/// <param name="contentType">The MIME type of the file to upload</param>
148150
/// <returns>This request</returns>
149-
IRestRequest AddFile(string name, byte[] bytes, string fileName);
151+
IRestRequest AddFile(string name, byte[] bytes, string fileName, string contentType = null);
150152

151153
/// <summary>
152154
/// Adds the bytes to the Files collection with the specified file name and content type
153155
/// </summary>
154156
/// <param name="name">The parameter name to use in the request</param>
155-
/// <param name="bytes">The file data</param>
157+
/// <param name="writer">A function that writes directly to the stream. Should NOT close the stream.</param>
156158
/// <param name="fileName">The file name to use for the uploaded file</param>
157159
/// <param name="contentType">The MIME type of the file to upload</param>
158160
/// <returns>This request</returns>
159-
IRestRequest AddFile(string name, byte[] bytes, string fileName, string contentType);
161+
IRestRequest AddFile(string name, Action<Stream> writer, string fileName, string contentType = null);
160162
#endif
161163

162164
/// <summary>

RestSharp/RestRequest.cs

Lines changed: 6 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,9 @@ public RestRequest(Uri resource, Method method)
120120
/// </summary>
121121
/// <param name="name">The parameter name to use in the request</param>
122122
/// <param name="path">Full path to file to upload</param>
123+
/// <param name="contentType">The MIME type of the file to upload</param>
123124
/// <returns>This request</returns>
124-
public IRestRequest AddFile(string name, string path)
125+
public IRestRequest AddFile(string name, string path, string contentType = null)
125126
{
126127
FileInfo f = new FileInfo(path);
127128
long fileLength = f.Length;
@@ -137,7 +138,8 @@ public IRestRequest AddFile(string name, string path)
137138
{
138139
file.BaseStream.CopyTo(s);
139140
}
140-
}
141+
},
142+
ContentType = contentType
141143
});
142144
}
143145

@@ -147,37 +149,13 @@ public IRestRequest AddFile(string name, string path)
147149
/// <param name="name">The parameter name to use in the request</param>
148150
/// <param name="bytes">The file data</param>
149151
/// <param name="fileName">The file name to use for the uploaded file</param>
150-
/// <returns>This request</returns>
151-
public IRestRequest AddFile(string name, byte[] bytes, string fileName)
152-
{
153-
return this.AddFile(FileParameter.Create(name, bytes, fileName));
154-
}
155-
156-
/// <summary>
157-
/// Adds the bytes to the Files collection with the specified file name and content type
158-
/// </summary>
159-
/// <param name="name">The parameter name to use in the request</param>
160-
/// <param name="bytes">The file data</param>
161-
/// <param name="fileName">The file name to use for the uploaded file</param>
162152
/// <param name="contentType">The MIME type of the file to upload</param>
163153
/// <returns>This request</returns>
164-
public IRestRequest AddFile(string name, byte[] bytes, string fileName, string contentType)
154+
public IRestRequest AddFile(string name, byte[] bytes, string fileName, string contentType = null)
165155
{
166156
return this.AddFile(FileParameter.Create(name, bytes, fileName, contentType));
167157
}
168158

169-
/// <summary>
170-
/// Adds the bytes to the Files collection with the specified file name and content type
171-
/// </summary>
172-
/// <param name="name">The parameter name to use in the request</param>
173-
/// <param name="writer">A function that writes directly to the stream. Should NOT close the stream.</param>
174-
/// <param name="fileName">The file name to use for the uploaded file</param>
175-
/// <returns>This request</returns>
176-
public IRestRequest AddFile(string name, Action<Stream> writer, string fileName)
177-
{
178-
return this.AddFile(name, writer, fileName, null);
179-
}
180-
181159
/// <summary>
182160
/// Adds the bytes to the Files collection with the specified file name and content type
183161
/// </summary>
@@ -186,7 +164,7 @@ public IRestRequest AddFile(string name, Action<Stream> writer, string fileName)
186164
/// <param name="fileName">The file name to use for the uploaded file</param>
187165
/// <param name="contentType">The MIME type of the file to upload</param>
188166
/// <returns>This request</returns>
189-
public IRestRequest AddFile(string name, Action<Stream> writer, string fileName, string contentType)
167+
public IRestRequest AddFile(string name, Action<Stream> writer, string fileName, string contentType = null)
190168
{
191169
return AddFile(new FileParameter
192170
{

0 commit comments

Comments
 (0)