diff --git a/src/Client.Helpers.cs b/src/Client.Helpers.cs index 9c7eafa..29c2eef 100644 --- a/src/Client.Helpers.cs +++ b/src/Client.Helpers.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.IO; using System.Linq; -using System.Reflection; using System.Security.Cryptography; using System.Threading; using System.Threading.Tasks; @@ -40,7 +39,7 @@ namespace WTelegram { bool hasLength = stream.CanSeek; long transmitted = 0, length = hasLength ? stream.Length : -1; - bool isBig = hasLength ? length >= 10 * 1024 * 1024 : true; + bool isBig = !hasLength || length >= 10 * 1024 * 1024; int file_total_parts = hasLength ? (int)((length - 1) / FilePartSize) + 1 : -1; long file_id = Helpers.RandomLong(); int file_part = 0, read; @@ -92,7 +91,7 @@ namespace WTelegram await Task.WhenAll(remainingTasks); // wait completion and eventually propagate any task exception if (!isBig) md5.TransformFinalBlock(Array.Empty(), 0, 0); return isBig ? new InputFileBig { id = file_id, parts = file_total_parts, name = filename } - : new InputFile { id = file_id, parts = file_total_parts, name = filename, md5_checksum = md5.Hash }; + : new InputFile { id = file_id, parts = file_total_parts, name = filename, md5_checksum = Convert.ToHexString(md5.Hash).ToLower() }; } } diff --git a/src/Helpers.cs b/src/Helpers.cs index 3231d95..50b445e 100644 --- a/src/Helpers.cs +++ b/src/Helpers.cs @@ -241,7 +241,7 @@ namespace WTelegram public long? ContentLength; protected readonly Stream _innerStream; public override bool CanRead => _innerStream.CanRead; - public override bool CanSeek => _innerStream.CanSeek; + public override bool CanSeek => ContentLength.HasValue || _innerStream.CanSeek; public override bool CanWrite => _innerStream.CanWrite; public override long Length => ContentLength ?? _innerStream.Length; public override long Position { get => _innerStream.Position; set => _innerStream.Position = value; } diff --git a/src/TL.Schema.cs b/src/TL.Schema.cs index 6efec45..eff054b 100644 --- a/src/TL.Schema.cs +++ b/src/TL.Schema.cs @@ -150,7 +150,7 @@ namespace TL /// Full name of the file public string name; /// In case the file's md5-hash was passed, contents of the file will be checked prior to use - public byte[] md5_checksum; + public string md5_checksum; /// Random file identifier created by the client public override long ID { get => id; set => id = value; } @@ -5481,7 +5481,7 @@ namespace TL /// Number of saved parts public int parts; /// In case md5-HASH of the (already encrypted) file was transmitted, file content will be checked prior to use - public byte[] md5_checksum; + public string md5_checksum; /// 32-bit fingerprint of the key used to encrypt a file public int key_fingerprint; @@ -10806,7 +10806,7 @@ namespace TL /// Secure file part count public int parts; /// MD5 hash of encrypted uploaded file, to be checked server-side - public byte[] md5_checksum; + public string md5_checksum; /// File hash public byte[] file_hash; /// Secret