Fixed SendFile

This commit is contained in:
RogueException
2015-12-02 13:09:07 -04:00
parent 142c03a1c2
commit 3ccd416027

View File

@@ -48,8 +48,14 @@ namespace Discord.Net.Rest
public Task<string> SendFile(string method, string path, string filename, Stream stream, CancellationToken cancelToken)
{
var request = new RestRequest(path, Method.POST);
request.AddFile("file", x => stream.CopyTo(x), filename);
return Send(request, cancelToken);
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);
}
private async Task<string> Send(RestRequest request, CancellationToken cancelToken)
{