protected async Task <string> UploadImage(string imageFile, int id, string imagePath, DateTime createdUtc) { if (!string.IsNullOrWhiteSpace(imageFile)) { var shippingMarkImageHash = SHA1.Hash(imageFile); if (!string.IsNullOrWhiteSpace(imagePath)) { var fileName = _azureImageService.GetFileNameFromPath(imagePath).Split("_"); if (fileName[3] != shippingMarkImageHash) { await _azureImageService.RemoveImage(IMG_DIR, imagePath); imagePath = await _azureImageService.UploadImage(IMG_DIR, GenerateFileName(id, createdUtc, shippingMarkImageHash), imageFile); } } else { imagePath = await _azureImageService.UploadImage(IMG_DIR, GenerateFileName(id, createdUtc, shippingMarkImageHash), imageFile); } } else { if (!string.IsNullOrWhiteSpace(imagePath)) { await _azureImageService.RemoveImage(IMG_DIR, imagePath); imagePath = null; } } return(imagePath); }
public async Task <int> LoadStickerSet(string stickerSetName) { var telegramStickerSet = await _telegramService.GetStickerSetAsync(stickerSetName); var stickerSet = CreateStickerSet(telegramStickerSet.Title, telegramStickerSet.Name); foreach (var sticker in telegramStickerSet.Stickers) { var memoryStream = new MemoryStream(); await _telegramService.DownloadSticker(sticker.FileId, memoryStream); memoryStream.Position = 0; var uri = await _azureImageService.UploadImage($"{sticker.FileId}.webp", memoryStream); CreateSticker(sticker.Emoji, sticker.FileId, null, stickerSet.Id, azureImageUrl: uri.AbsoluteUri); } return(stickerSet.Id); }