00642 Cannot send a file (stream) without caption
See original GitHub issueOn trying (build 00642)
await Context.Channel.SendFileAsync(stream, $"{mod}.png", null);
I get:
Exception: The server responded with error 50006: Cannot send an empty message
This is strange behaviour, as the default value for text is null. The file sends without errors if I specify a caption. Haven’t tested when passing a path.
Edit: TC: I was using client.GetStreamAsync, the following example will result in the mentioned error:
using (var client = new System.Net.Http.HttpClient())
using (var testStream = await client.GetStreamAsync(url))
await Context.Channel.SendFileAsync(testStream, "image.png");
while the following does not give this error:
using (var client = new System.Net.Http.HttpClient())
{
var response = await client.GetByteArrayAsync(url);
using (var stream = new MemoryStream(response))
await Context.Channel.SendFileAsync(stream, "image.png");
}
Issue Analytics
- State:
- Created 7 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
Can't upload VTT caption files
For the past month or so, I have been completely unable to upload .vtt captions files to videos hosted on SharePoint/SP Streams.
Read more >c# - Using FileStream without an actual file
In this scenario you should just use a MemoryStream , and ensure your API just demands Stream rather than FileStream specifically.
Read more >Creating text file using stream but not writing to disk
I am sending the content as a byte[] to a web service. I could use something like this, but i do not want...
Read more >filestream input | Filebeat Reference [8.9]
Without a unique ID, filestream is unable to correctly track the state of files. You can apply additional configuration settings (such as fields...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I suspect it’s related to this part of HttpClient: https://github.com/dotnet/corefx/blob/master/src/System.Net.Http/src/System/Net/Http/StreamContent.cs#L69
Since the download stream is not seekable, the stream length is unknown and I assume it doesn’t report
content-length
to Discord. https://github.com/RogueException/Discord.Net/commit/35d7a0cec89398a69fd5d3472fe6980f327f5d00 should fix this by copying to a memory stream if the provided stream’sCanSeek
is false.@RogueException Yup, seems to work properly now. Thanks.