private byte[] FetchFileBytes(FileLocation fileLocation,uint offset,uint limit) { if (fileLocation.DcId == _settings.NearestDcId) { using (var clientDisposable = new FullClientDisposable(this)) { return FetchFileBytes(clientDisposable.Client, fileLocation,offset,limit); } } else { try { var client = GetClient((int)fileLocation.DcId); return FetchFileBytes(client, fileLocation,offset,limit); } catch (Exception ex) { DebugPrint("Failed to obtain client from DC manager: " + ex); return null; } } }
private static byte[] FetchFileBytes(TelegramClient client, FileLocation fileLocation) { try { 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; } catch (Exception ex) { Utils.DebugPrint("Exception while fetching file bytes"); return null; } }
private static byte[] FetchFileBytes(TelegramClient client, FileLocation fileLocation, uint offset, uint limit) { var response = (UploadFile)TelegramUtils.RunSynchronously(client.Methods.UploadGetFileAsync( new UploadGetFileArgs { Location = new InputFileLocation { VolumeId = fileLocation.VolumeId, LocalId = fileLocation.LocalId, Secret = fileLocation.Secret }, Offset = offset, Limit = limit, })); return response.Bytes; }
private async Task<IUploadFile> FetchFileBytes(TelegramClient client, FileLocation thumbnailLocation) { return await client.Methods.UploadGetFileAsync(new UploadGetFileArgs { Location = new InputFileLocation { VolumeId = thumbnailLocation.VolumeId, LocalId = thumbnailLocation.LocalId, Secret = thumbnailLocation.Secret }, Offset = 0, Limit = uint.MaxValue, }); }