コード例 #1
0
ファイル: Telegram.cs プロジェクト: harper10/DisaOpenSource
 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;
         }
     }
 }
コード例 #2
0
ファイル: Telegram.cs プロジェクト: harper10/DisaOpenSource
        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;
            }

        }
コード例 #3
0
ファイル: Telegram.cs プロジェクト: harper10/DisaOpenSource
 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;
 }
コード例 #4
0
ファイル: Settings.cs プロジェクト: Xanagandr/DisaOpenSource
 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,
     });
 }