FILE_REFERENCE_EXPIRED at upload.getFile with inputPhotoFileLocation using mtproto/core

31 views Asked by At

Can't get content from method upload.getFile using inputPhotoFileLocation, getting exeption FILE_REFERENCE_EXPIRED, Tried everything I got from the internet. using MTProto client on js

await TelegramAPI.call("upload.getFile", {
    location: {
      _: "inputPhotoFileLocation",
      id: Image[0].media.photo.id,
      access_hash: Image[0].media.photo.access_hash,
      file_reference: Image[0].media.photo.file_reference,
      thumb_size: Image[0].media.photo.sizes.find(
        (size: any) => size._ == "photoSizeProgressive"
      ).type,
    },

    offset: 0,
    limit: 1024 * 1024,
  })

I just want to get image data from the saved messages.

1

There are 1 answers

0
sagarbhusal01 On

this did the trick for me

export const GetImageData = async (FilteredImageData: any) => {
  let ImageURI = await Promise.all(
    FilteredImageData.map(async (names: any) => {
      return await TelegramAPI.call("upload.getFile", {
        location: {
          _: "inputPhotoFileLocation",
          id: names.media.photo.id,
          access_hash: names.media.photo.access_hash,
          file_reference: names.media.photo.file_reference,
          thumb_size: names.media.photo.sizes.find(
            (size: any) => size._ == "photoSizeProgressive"
          ).type,
        },

        offset: 0,
        limit: 1024 * 1024,
      })
        .catch((e: any) => {
          console.log(e);
        })
        .then((Bytes: any) => {
          return {
            uri:
              "data:image/jpeg;base64," +
              Buffer.from(Bytes.bytes).toString("base64"),
          };
        });
    })
  );
  return ImageURI;
};