uploadStickerFile method

Future<File> uploadStickerFile(
  1. int user_id,
  2. File png_sticker
)
inherited

Use this method to upload a .png file with a sticker for later use in createNewStickerSet and addStickerToSet methods (can be used multiple times)

Returns the uploaded File on success.

https://core.telegram.org/bots/api#uploadstickerfile

Implementation

Future<File> uploadStickerFile(int user_id, io.File png_sticker) async {
  var requestUrl = _apiUri('uploadStickerFile');
  var body = <String, dynamic>{'user_id': user_id};
  // filename cannot be empty to post to Telegram server
  var files = List<MultipartFile>.filled(
      1,
      MultipartFile(
          'png_sticker', png_sticker.openRead(), png_sticker.lengthSync(),
          filename: '${png_sticker.lengthSync()}'));
  return File.fromJson(
      await HttpClient.httpMultipartPost(requestUrl, files, body: body));
}