diff --git a/src/Client.cs b/src/Client.cs
index e31425a..9985648 100644
--- a/src/Client.cs
+++ b/src/Client.cs
@@ -902,6 +902,48 @@ namespace WTelegram
return this.Messages_SendMedia(peer, media, text, Helpers.RandomLong(),
reply_to_msg_id: reply_to_msg_id, entities: entities, schedule_date: schedule_date);
}
+
+ /// Download given photo from Telegram into the outputStream
+ /// stream to write to. This method does not close/dispose the stream
+ /// if unspecified, will download the largest version of the photo
+ public async Task DownloadFileAsync(Photo photo, Stream outputStream, PhotoSizeBase photoSize = null)
+ {
+ var fileLocation = photo.ToFileLocation(photoSize ?? photo.LargestPhotoSize);
+ await MigrateDCAsync(photo.dc_id);
+ return await DownloadFileAsync(fileLocation, outputStream);
+ }
+
+ /// Download given photo from Telegram into the outputStream
+ /// stream to write to. This method does not close/dispose the stream
+ /// if specified, will download the given thumbnail instead of the full document
+ public async Task DownloadFileAsync(Document document, Stream outputStream, PhotoSizeBase thumbSize = null)
+ {
+ var fileLocation = document.ToFileLocation(thumbSize);
+ await MigrateDCAsync(document.dc_id);
+ return await DownloadFileAsync(fileLocation, outputStream);
+ }
+
+ /// Download given file from Telegram into the outputStream
+ /// Telegram file identifier, typically obtained with a .ToFileLocation() call
+ /// stream to write to. This method does not close/dispose the stream
+ public async Task DownloadFileAsync(InputFileLocationBase fileLocation, Stream outputStream)
+ {
+ const int ChunkSize = 128 * 1024;
+ int fileSize = 0;
+ Upload_File fileData;
+ do
+ {
+ var fileBase = await this.Upload_GetFile(fileLocation, fileSize, ChunkSize);
+ fileData = fileBase as Upload_File;
+ if (fileData == null)
+ throw new ApplicationException("Upload_GetFile returned unsupported " + fileBase.GetType().Name);
+ await outputStream.WriteAsync(fileData.bytes, 0, fileData.bytes.Length);
+ fileSize += fileData.bytes.Length;
+
+ } while (fileData.bytes.Length == ChunkSize);
+ await MigrateDCAsync(); // migrate back to main DC
+ return fileData.type;
+ }
#endregion
/// Enable the collection of id/access_hash pairs (experimental)
diff --git a/src/Generator.cs b/src/Generator.cs
index 1ae51cd..599e2ed 100644
--- a/src/Generator.cs
+++ b/src/Generator.cs
@@ -337,6 +337,7 @@ namespace WTelegram
private void WriteTypeAsEnum(StreamWriter sw, TypeInfo typeInfo)
{
enumTypes.Add(typeInfo.ReturnName);
+ bool lowercase = typeInfo.ReturnName == "Storage_FileType";
sw.WriteLine($"{tabIndent}public enum {typeInfo.ReturnName} : uint");
sw.WriteLine($"{tabIndent}{{");
string prefix = "";
@@ -348,6 +349,7 @@ namespace WTelegram
{
string className = CSharpName(ctor.predicate);
if (!allTypes.Add(className)) continue;
+ if (lowercase) className = className.ToLowerInvariant();
ctorToTypes.Remove(ctor.ID);
sw.WriteLine($"{tabIndent}\t///See ");
sw.WriteLine($"{tabIndent}\t{className[prefixLen..]} = 0x{ctor.ID:X8},");
diff --git a/src/TL.Schema.cs b/src/TL.Schema.cs
index 0147764..80dd9d0 100644
--- a/src/TL.Schema.cs
+++ b/src/TL.Schema.cs
@@ -413,25 +413,25 @@ namespace TL
public enum Storage_FileType : uint
{
///See
- Unknown = 0xAA963B05,
+ unknown = 0xAA963B05,
///See
- Partial = 0x40BC6F52,
+ partial = 0x40BC6F52,
///See
- Jpeg = 0x007EFE0E,
+ jpeg = 0x007EFE0E,
///See
- Gif = 0xCAE1AADF,
+ gif = 0xCAE1AADF,
///See
- Png = 0x0A4F63C0,
+ png = 0x0A4F63C0,
///See
- Pdf = 0xAE1E508D,
+ pdf = 0xAE1E508D,
///See
- Mp3 = 0x528A0677,
+ mp3 = 0x528A0677,
///See
- Mov = 0x4B09EBBC,
+ mov = 0x4B09EBBC,
///See
- Mp4 = 0xB3CEA0E4,
+ mp4 = 0xB3CEA0E4,
///See
- Webp = 0x1081464C,
+ webp = 0x1081464C,
}
///See