Exemple #1
0
        /// <summary>
        /// Provides detailed information for a File and the content of the File based on the fileId.
        /// </summary>
        /// <param name="telegramBot">Extended object</param>
        /// <param name="fileId">Identifier of the file.</param>
        /// <returns>Tupel of a file and the byte array that represents the file.</returns>
        public static async Task <(File file, byte[] content)> GetFileAndDownloadByteArray(this TelegramBot telegramBot, string fileId)
        {
            var file = await telegramBot.GetFile(fileId);

            var content = await telegramBot.DownloadFileByteArray(file.FilePath);

            return(file, content);
        }
Exemple #2
0
        /// <summary>
        /// Provides detailed information for a File and the content of the File based on the fileId.
        /// </summary>
        /// <param name="telegramBot">Extended object</param>
        /// <param name="fileId">Identifier of the file.</param>
        /// <returns>Tupel of a file and a stream that represents the file.</returns>
        public static async Task <(File file, Stream content)> GetFileAndDownloadStream(this TelegramBot telegramBot, string fileId)
        {
            var file = await telegramBot.GetFile(fileId);

            var content = await telegramBot.DownloadFileStream(file.FilePath);

            return(file, content);
        }
Exemple #3
0
        public void GetFile_Returns_GetFileBytes_Returns()
        {
            User testUser = new User()
            {
                Id = 20793245
            };
            var m1 = _b.GetUserProfilePhotos(testUser);

            if (m1.Count > 0)
            {
                var result = _b.GetFile(m1[0][0].FileId);
                Assert.NotNull(result);
                Assert.NotNull(result.FileId);
                Assert.NotNull(result.FilePath);
                Assert.NotNull(result.FileSize);
                var bytes = _b.GetFileContent(result);
                Assert.NotNull(bytes);
                Assert.That(bytes.Length > 0);
                var m2 = _b.SendDocument(_testMessage.Chat, new InputFile(bytes, "fileTransferTest", "img/jpeg"));
                Assert.NotNull(m2);
                Assert.NotNull(m2.Document);
            }
        }