Fixed SendFile
This commit is contained in:
@@ -48,7 +48,13 @@ namespace Discord.Net.Rest
|
|||||||
public Task<string> SendFile(string method, string path, string filename, Stream stream, CancellationToken cancelToken)
|
public Task<string> SendFile(string method, string path, string filename, Stream stream, CancellationToken cancelToken)
|
||||||
{
|
{
|
||||||
var request = new RestRequest(path, Method.POST);
|
var request = new RestRequest(path, Method.POST);
|
||||||
request.AddFile("file", x => stream.CopyTo(x), filename);
|
request.AddHeader("content-length", (stream.Length - stream.Position).ToString());
|
||||||
|
|
||||||
|
byte[] bytes = new byte[stream.Length - stream.Position];
|
||||||
|
stream.Read(bytes, 0, bytes.Length);
|
||||||
|
request.AddFileBytes("file", bytes, filename);
|
||||||
|
//request.AddFile("file", x => stream.CopyTo(x), filename); (Broken in latest ver)
|
||||||
|
|
||||||
return Send(request, cancelToken);
|
return Send(request, cancelToken);
|
||||||
}
|
}
|
||||||
private async Task<string> Send(RestRequest request, CancellationToken cancelToken)
|
private async Task<string> Send(RestRequest request, CancellationToken cancelToken)
|
||||||
|
|||||||
Reference in New Issue
Block a user