Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File downloads from telegram fails periodically #293

Open
knitershift opened this issue Oct 1, 2024 · 1 comment
Open

File downloads from telegram fails periodically #293

knitershift opened this issue Oct 1, 2024 · 1 comment

Comments

@knitershift
Copy link

Hello, wiz0u. sometimes I get errors while downloading file, now it's like 1/10 downloads ends with error. (on production server)
Could you please check this part of code, that works with memory streem?
The exception describes itself like:
System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.\\n at System.IO.MemoryStream.set_Capacity(Int32 value)\\n at System.IO.MemoryStream.EnsureCapacity(Int32 value)\\n at System.IO.MemoryStream.Write(Byte[] buffer, Int32 offset, Int32 count)\\n at System.IO.MemoryStream.WriteAsync(Byte[] buffer, Int32 offset, Int32 count, CancellationToken cancellationToken)\\n--- End of stack trace from previous location ---\\n at WTelegram.Client.<>c__DisplayClass144_0.<<DownloadFileAsync>g__LoadPart|0>d.MoveNext()\\n--- End of stack trace from previous location ---\\n at WTelegram.Client.DownloadFileAsync(InputFileLocationBase fileLocation, Stream outputStream, Int32 dc_id, Int64 fileSize, ProgressCallback progress)\\n at WTelegram.Client.DownloadFileAsync(Document document, Stream outputStream, PhotoSizeBase thumbSize, ProgressCallback progress)...

@ishare2121
Copy link

byte[] bytes = null;
using (MemoryStream stream = new MemoryStream())
{
await clientBot.Client.DownloadFileAsync(photo, stream);
bytes = await stream.ToArrayAsync();
}
下载OK的。我需要byte[]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants