Answer the question
In order to leave comments, you need to log in
How to save a file sent to a chat bot to a specific folder on a PC?
When sending a File to a bot, it saves it not to the specified folder, but to the root of the project, and even empty
. Please see what's wrong?
@dp.message_handler(content_types=[types.ContentType.DOCUMENT])
async def scan_doc(message: types.document):
doc_name = message.document.file_name
await message.answer("Document loaded: " + doc_name)
await bot.download_file ("C:\\doki", doc_name)
Answer the question
In order to leave comments, you need to log in
https://docs.aiogram.dev/en/dev-3.x/api/download_f...
The first parameter is the path on the telegram server, the second is the file name. You have the first one - a folder with a PC, and the second one - a file name (not even a path)
ps why is the type annotation made as if it is not a document that comes, but
await bot.download(message.document, 'C:\\file')
message: types.document
message
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question