Exemplo n.º 1
0
 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;
         }
     }
 }
Exemplo n.º 2
0
        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;
            }

        }
Exemplo n.º 3
0
 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;
 }
Exemplo n.º 4
0
 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,
     });
 }