uploadStickerFile method

Future<File> uploadStickerFile(
  1. int userId,
  2. File sticker,
  3. String stickerFormat
)

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 userId, io.File sticker, String stickerFormat) async {
  var requestUrl = _apiUri('uploadStickerFile');
  var body = <String, dynamic>{
    'user_id': userId,
    'sticker_format': stickerFormat,
  };

  var files = List<MultipartFile>.from([
    MultipartFile('sticker', sticker.openRead(), sticker.lengthSync(),
        filename: '${sticker.lengthSync()}')
  ]);

  return File.fromJson(
      await HttpClient.httpMultipartPost(requestUrl, files, body: body));
}