question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

00642 Cannot send a file (stream) without caption

See original GitHub issue

On 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:closed
  • Created 7 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
Auralyticalcommented, Mar 22, 2017

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’s CanSeek is false.

0reactions
Jofairdencommented, Apr 7, 2017

@RogueException Yup, seems to work properly now. Thanks.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found