404, message=’Not Found ,I can’t download a file sent by the user

Hello everyone I am writing a telegram bot that downloads files sent by the user, but I get this exception:404, message=’Not Found. I’ve been racking my brain for a long time about what, I’ve searched the entire Internet, but I haven’t found anything. I write in python using the aoigram3 library, the code works on my PC, but the remote local server throws this exception, I will be glad of your help, thanks for earlier.

TOKEN=""
session = AiohttpSession(api = TelegramAPIServer.from_base('http://localhost:8081'))
bot = Bot(TOKEN,session=session)
dp = Dispatcher()
a= logging.basicConfig(level=logging.INFO)
save_path_apk = None
file_info = None
class Form_apk(StatesGroup):
    opisanie = State()
    apk = State()
    photo = State()
class Form_post(StatesGroup):
    photo = State()
    opisanie = State()
async def the_re_assembly_APK(message:Message,files,thumbnail,caption):
    try:
        await bot.send_document(document=files, chat_id=-1001161287029, thumbnail=thumbnail,
                                caption=caption)
        directory_image = glob.glob(r'/root/hosting_bot/DATA/IMAGE*')
        directory_apk = glob.glob(r'/root/hosting_bot/DATA/APK*')
        for f in directory_image:
            os.remove(f)
        for f in directory_apk:
            os.remove(f)
    except:
        await message.answer(text="Ошибка")
        d_i = r'/root/hosting_bot/DATA/IMAGE*'
        d_apk = r'/root/hosting_bot/DATA/APK*'
        if os.path.isdir(d_apk):
            if not os.listdir(d_apk):
                await message.answer(text="Загрузите ваш файл с расширением .apk")
        if os.path.isdir(d_i):
            if not os.listdir(d_i):
                await message.answer(text="Загрузите ваше изображение")
@dp.message(Command("start"))
async def command_start_hendler(message: Message):
    kb = [[KeyboardButton(text="APK Constructor⚙️"),KeyboardButton(text="Post Constructor????")]]
    keyboard = ReplyKeyboardMarkup(keyboard=kb, resize_keyboard=True)
    await message.answer(f"Здравствуйте {message.from_user.full_name}",reply_markup=keyboard)

@dp.message(lambda message: message.text == "APK Constructor⚙️")
async def apk_file_setting(message:Message,state:FSMContext):
    await state.set_state(Form_apk.opisanie)
    await message.answer("Отправьте описание файла ????:")

@dp.message(Form_apk.opisanie)
async def form_opisanie(message:Message,state:FSMContext):
    await state.update_data(opisanie=message.text)
    await state.set_state(Form_apk.apk)
    await message.answer("Отправьте файл с расширением .apk????")

@dp.message(Form_apk.apk, F.document)
async def form_apk(message:Message,state:FSMContext):
    try:
        f = message.document.file_name
        basename, extension = os.path.splitext(f)
        if extension == ".apk":
            #PROBLEM CODE
                down = await message.answer(text="Скачивается ⬇️")
                await message.answer(text="1")
                global file_info
                file_info = await bot.get_file(message.document.file_id)
                await message.answer(text="2")
                global save_path_apk
                save_path_apk = rf'/root/hosting_bot/APK'
                #asa = 'https://api.telegram.org/file/bot<token>/<file_path> to get the file.'
                ##time.sleep(10)
                downlaod_apk=await bot.download_file(file_path=file_info.file_path,destination=save_path_apk)
                await message.answer(text="4")
                global file_name_apk
                file_name_apk = os.path.join(save_path_apk,f'{message.document.file_name}')
                await message.answer(text="5")
                with open('/root/hosting_bot/APK'+file_name_apk,"wb") as new_file:
                    await message.answer(text="6")
                    new_file.write(downlaod_apk.read())
                    await message.answer(text="7")
                await bot.delete_message(chat_id=message.chat.id, message_id=down.message_id)
                await message.answer(text="8")
                global files
                await message.answer(text="9")

                # files = FSInputFile(file_name_apk)
                # await message.answer(text="10")
                await message.answer("Скачано ✔️")
                # await state.update_data(apk=files)
                # await state.set_state(Form_apk.photo)
                # await message.answer("Отправьте изображение ????️")
            #PROBLEM CODE
        else:
            await message.answer(text="Ошибка❗ Отправьте файл с расширением .apk????")
    except aiohttp.client_exceptions.ClientResponseError as e:
            await message.answer(text=f"{e}")
            #await message.answer(f"URL запроса: {file_info.file_path}")

@dp.message(Form_apk.photo, F.photo)
async def form_photo(message:Message,state:FSMContext):
        photo_id = message.photo[-1]
        file_info = await bot.get_file(photo_id.file_id)
        global save_path
        save_path = r'/root/hosting_bot/DATA/IMAGE'
        download_photo = await bot.download_file(file_info.file_path)
        global file_name
        file_name = os.path.join(save_path, f'photo_{photo_id.file_id}.jpg')
        global new_file
        with open(file_name, "wb") as new_file:
            new_file.write(download_photo.read())
        global thumbnail
        thumbnail = FSInputFile(file_name)
        await message.answer("Скачано ✔️")
        await state.update_data(photo=thumbnail)
        data = await state.get_data()
        await the_re_assembly_APK(message,data["apk"],data["photo"],data["opisanie"])
        await message.answer("Apk отправлен в канал ✔️")
        await state.clear()

@dp.message(Form_apk.photo, ~F.photo)
async def form_photo(message:Message):
    await message.answer("Отправьте изображание ????️")

@dp.message(lambda message: message.text == "Post Constructor????")
async def apk_file_setting(message:Message,state:FSMContext):
    await state.set_state(Form_post.photo)
    await message.answer(text="Отправьте изображение ????️")

@dp.message(Form_post.photo,F.photo)
async def form_photo_post(message:Message,state:FSMContext):
        photo_id = message.photo[-1]
        await state.update_data(photo=photo_id.file_id)
        await state.set_state(Form_post.opisanie)
        await message.answer(text="Отправьте описание ????:")

@dp.message(Form_post.photo,~F.photo)
async def form_photo_post(message:Message,state:FSMContext):
        await message.answer(text="Ошибка❗ Вы отправили не изображение ❌")
        await message.answer(text="Отправьте изображение ????️")

@dp.message(Form_post.opisanie,F.text)
async def form_photo_post(message:Message,state:FSMContext):
        await state.update_data(opisanie=message.text)
        #global data
        data = await state.get_data()
        await bot.send_photo(chat_id=-1001161287029,photo=data["photo"],caption=data["opisanie"])
        #await bot.send_photo(chat_id=,photo=data["photo"],caption=data["opisanie"])
        await message.answer(text="Пост отправлен в канал ✔️")
        await state.clear()

@dp.message(Form_post.opisanie, ~F.text)
async def form_photo_post(message: Message, state: FSMContext):
    await message.answer(text="Ошибка❗ Вы отправили не текст")


async def main():
    try:
        await dp.start_polling(bot)
    except TelegramAPIError as e:
        if isinstance(e,asyncio.TimeoutError):
            print(e)
asyncio.run(main())

New contributor

ProgrammerBandit is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật