private byte[] FetchFileBytes(FileLocation fileLocation) { if (fileLocation.DcId == _settings.NearestDcId) { using (var clientDisposable = new TelegramClientDisposable(this)) { return FetchFileBytes(clientDisposable.Client, fileLocation); } } else { try { var client = GetClient((int)fileLocation.DcId); return FetchFileBytes(client, fileLocation); } catch (Exception ex) { DebugPrint("Failed to obtain client from DC manager: " + ex); return null; } } }
//TODO: chunk the download private static byte[] FetchFileBytes(TelegramClient client, FileLocation fileLocation) { var response = (UploadFile)TelegramUtils.RunSynchronously(client.Methods.UploadGetFileAsync( new UploadGetFileArgs { Location = new InputFileLocation { VolumeId = fileLocation.VolumeId, LocalId = fileLocation.LocalId, Secret = fileLocation.Secret }, Offset = 0, Limit = uint.MaxValue, })); return response.Bytes; }