tdlib / td

Cross-platform library for building Telegram clients
https://core.telegram.org/tdlib
Boost Software License 1.0
7.04k stars 1.44k forks source link

Unable to use downloadFile #3063

Open mahajanparas09 opened 1 week ago

mahajanparas09 commented 1 week ago

I am using TDL which is a javascript wrapper for TDLib. Following is my code to download a file. When I run this code I get updateFile logged twice in the console. The first time it says "is_downloading_active": true and "is_downloading_completed": false. The second time it says "is_downloading_active": false, "is_downloading_completed": false, "downloaded_size": 0. Why didn't file got downloaded. I can clearly see the file which is an image in my telegram app so definitely file is there.

client.on('update', onUpdate);

async function main () {
    await client.login()

    const chat = await client.invoke({
        _: 'getChat',
        chat_id: -702279442
    })

    let fileID = chat.last_message.content.photo.sizes[2].photo.id;

    const download = await client.invoke({
        _: 'downloadFile',
        file_id: fileID,
        priority: 32
    });

    await client.close()
  }

function onUpdate(upd){
    if (upd['_'] === 'updateFile'){
        console.log(upd);
    }
}

main().catch(console.error)
Hanis123456 commented 1 week ago

client.on('update', onUpdate);

async function main () { await client.login()

const chat = await client.invoke({
    _: 'getChat',
    chat_id: -702279442
})

let fileID = chat.last_message.content.photo.sizes[2].photo.id;

const download = await client.invoke({
    _: 'downloadFile',
    file_id: fileID,
    priority: 32
});

await client.close()

}

function onUpdate(upd){ if (upd['_'] === 'updateFile'){ console.log(upd); } }

main().catch(console.error)

levlam commented 1 week ago

Check TDLib logs with verbosity level 2.