Giter Site home page Giter Site logo

Comments (7)

savely-krasovsky avatar savely-krasovsky commented on August 24, 2024

@vtolstov you should use upload.getFile method. Of course at first you should get volume_id, local_id and secret.

Example:

res, err := t.mtproto.InvokeSync(mtproto.TL_upload_getFile{
	Location: mtproto.TL_inputFileLocation{
		Volume_id: volumeId,
		Local_id:  localId,
		Secret:    secret,
	},
	Offset: offset,
	Limit:  65536,
})
if err != nil {
	return nil, err
}

switch (*res).(type) {
case mtproto.TL_upload_file:
	return (*res).(mtproto.TL_upload_file).Bytes, nil
}

return nil, errors.New("UNKNOWN TYPE RETURNED")

from mtproto.

vtolstov avatar vtolstov commented on August 24, 2024

Wow THANKS!

from mtproto.

savely-krasovsky avatar savely-krasovsky commented on August 24, 2024

@vtolstov there is some problem right now. You could download files only from Data Center that you use. For Russia and CIS Telegram prefers second DC, for example. If you will try to download file from another DC you will get error FILE_MIGRATE_dcNumber.

But contributitions are welcome :)

from mtproto.

vtolstov avatar vtolstov commented on August 24, 2024

Hmm. i have mtproto.TL_fileLocation and not mtproto.TL_inputFileLocation

from mtproto.

vtolstov avatar vtolstov commented on August 24, 2024

and i'm from russia =)

from mtproto.

savely-krasovsky avatar savely-krasovsky commented on August 24, 2024

@vtolstov mtproto.TL_fileLocation you have in answer from Telegram with file. TL_inputFileLocation should used to request it.

from mtproto.

savely-krasovsky avatar savely-krasovsky commented on August 24, 2024

Example to get fileLocation variables:

if user, ok := res.(mtproto.TL_user); ok {
	if photo, ok := user.Photo.(mtproto.TL_userProfilePhoto); ok {
		if photoSmall, ok := photo.Photo_small.(mtproto.TL_fileLocation); ok {
			return Photo{
				photoSmall.Dc_id
				photoSmall.Volume_id,
				photoSmall.Local_id,
				photoSmall.Secret,
			}
		}
	}
}

And then use it upload.getFile method.

from mtproto.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.