'How to save file which was sent to telebot from user Python?

I need to save a file which was sent to telegram bot.

import telebot
bot = "Here is my token"

@bot.message_handler(content_types='') #IDK what content type I need to use to receive every file
def addfile(message):
#Here I need to save file which was sent


Solution 1:[1]

That would look something like this:

@bot.message_handler(content_types=['document', 'photo', 'audio', 'video', 'voice']) # list relevant content types
def addfile(message):
    file_name = message.document.file_name
    file_info = bot.get_file(message.document.file_id)
    downloaded_file = bot.download_file(file_info.file_path)
    with open(file_name, 'wb') as new_file:
        new_file.write(downloaded_file)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1