mtproto-core
mtproto-core copied to clipboard
API.call upload.getFile w/ constructor inputPhotoFileLocation return nothing
Dudes, i have a problem:
@mtproto/core v6.0.1 node v14.17.4
When i use method upload.getFile with constructor inputPhotoFileLocation, call return nothing w/o exception or error and cpu load about 100% for pending promise.
const photo_response = await api.call('upload.getFile', params);
e.g. params of method call:
{ location: { _: 'inputPhotoFileLocation', id: 'photo_id_from_photo_object', access_hash: 'access_hash_from_photo_object', file_reference: new Binary(Buffer.from("some_binary_code_here", "hex"), 0), thumb_size: 'y' }, offset: 0, limit: photo_size }
Can u help me w/ download photo by using new API constructor - inputPhotoFileLocation ?
Solution:
- U need recompile bytes string from file_reference represent for request (it's not working w/o Buffer - wrong bytes represent)
- U need setting up limit = 1024* 1024 (this is max value, any values not working, even despite the limits from the API documentation, idk why)
let buf = message.media.photo.file_reference; Buffer.from(buf.toString('hex'), 'hex') { location: { _: 'inputPhotoFileLocation', id: 'photo_id_from_photo_object', access_hash: 'access_hash_from_photo_object', file_reference: buf, //Hope this solution helps someone.