TLSharp icon indicating copy to clipboard operation
TLSharp copied to clipboard

fileref_upgrade_needed

Open daparici opened this issue 6 years ago • 29 comments

Hi,

I'm trying to download a few old files from one Telegram channel. I first send the file download request calling GetFile including TLInputDocumentFileLocation,filepartsize and offset. Telegram servers, with this kind of files, allways respond with floodpreventiongexception and I must wait 5000 milisececonds, then I request the file again using the same data and Telegram responds with a fileref_needs_upgrade.

I tried to refetch the document reference calling a GetHistoryAsync but the Location obtained doesn't change.

Does anybody know how to refresh/upgrade the document reference?

Thanks in advance.

daparici avatar Oct 22 '19 15:10 daparici

Does anybody have a solution of that? I am stucking on it.

Thanks.

Mubo-412 avatar Nov 18 '19 00:11 Mubo-412

I also have the same problem...

Xmg92 avatar Nov 18 '19 06:11 Xmg92

Any updates? I have the same issue with getting image message.

YitzchakYeret avatar Nov 30 '19 19:11 YitzchakYeret

Same issue here. Any news?

dariooo512 avatar Jan 04 '20 21:01 dariooo512

Yes. I stoped using TLSharp cause it seems dead. Now I'm using TDSharp based on TDLib and it works like a charm.

Please don't hesitate to ask me if you think I can help you in any other way.

daparici avatar Jan 04 '20 23:01 daparici

Hi @daparici thanks for your answer!

Well, that's disappointing since I've almost completed my application using TLSharp. I was searching for samples of the usage of TDSharp. Do you know where I can find one? (Simple stuff, like auth and get chats)

I'm asking you this here so maybe someone like me can have a chance to change lib before running into my situation :)

Thanks a lot!

dariooo512 avatar Jan 05 '20 22:01 dariooo512

Hi Dario,

Attached you will find an uncompleted sample showing how to auth and get the first 100 subscribed channels. TelegramController.txt

Please let me know if you have any problem.

daparici avatar Jan 07 '20 19:01 daparici

Awesome! Thanks a lot!

dariooo512 avatar Jan 07 '20 23:01 dariooo512

Hello Everyone, Is there any update about this issue? Sometimes it works for me, other times it doesn't. Is there any explication?

Mubo-412 avatar Feb 18 '20 13:02 Mubo-412

I also have the same problem...

ehsanasgarian avatar Mar 10 '20 11:03 ehsanasgarian

to download some files/docs library needs to support file references (update schema required), file location param seems to be deprecated: https://core.telegram.org/constructor/fileLocationToBeDeprecated

skipme avatar Mar 19 '20 10:03 skipme

(update schema required)

Hey @skipme, can you help us update the schema?

knocte avatar Mar 19 '20 11:03 knocte

to download some files/docs library needs to support file references (update schema required), file location param seems to be deprecated: https://core.telegram.org/constructor/fileLocationToBeDeprecated

Hey skipme. Could you give me a sample examples? My project is almost completed on TLSharp, so I don't want to change to TDLib. Thank you very much!

Jycjmf avatar Aug 10 '20 03:08 Jycjmf

I've managed to found This repo where there's an updated version with this problem solved.

The new code to get it working is

if (!(message.Media is TLMessageMediaPhoto media) || !(media.Photo is TLPhoto photo))
{
     continue;
}

var size = photo.Sizes.OfType<TLPhotoSize>().Last();
 var request = new TLInputPhotoFileLocation
 {
     Id = photo.Id,
     FileReference = photo.FileReference,
     AccessHash = photo.AccessHash,
     ThumbSize = size.Type
};
var buffer = await _client.GetFile(request, 1024 * 512);

I've fixed some namespaces and i'm using those dlls in my project now while i wait for the authors to merge the update TgSharp.TL.zip

On this version i'm having issues while managing the ISessionStore, but the rest is working fine.

dariooo512 avatar Aug 10 '20 08:08 dariooo512

I've managed to found This repo where there's an updated version with this problem solved.

The new code to get it working is

if (!(message.Media is TLMessageMediaPhoto media) || !(media.Photo is TLPhoto photo))
{
     continue;
}

var size = photo.Sizes.OfType<TLPhotoSize>().Last();
 var request = new TLInputPhotoFileLocation
 {
     Id = photo.Id,
     FileReference = photo.FileReference,
     AccessHash = photo.AccessHash,
     ThumbSize = size.Type
};
var buffer = await _client.GetFile(request, 1024 * 512);

I've fixed some namespaces and i'm using those dlls in my project now while i wait for the authors to merge the update TgSharp.TL.zip

On this version i'm having issues while managing the ISessionStore, but the rest is working fine.

Hey, dariooo512. Thanks very much! By the way, how did you fixed the namespaces? I am fixing it manually, it is really a massive project. Or could you give me the fixed source code, I want to modify something.

Jycjmf avatar Aug 10 '20 11:08 Jycjmf

I've managed to found This repo where there's an updated version with this problem solved.

The new code to get it working is

if (!(message.Media is TLMessageMediaPhoto media) || !(media.Photo is TLPhoto photo))
{
     continue;
}

var size = photo.Sizes.OfType<TLPhotoSize>().Last();
 var request = new TLInputPhotoFileLocation
 {
     Id = photo.Id,
     FileReference = photo.FileReference,
     AccessHash = photo.AccessHash,
     ThumbSize = size.Type
};
var buffer = await _client.GetFile(request, 1024 * 512);

I've fixed some namespaces and i'm using those dlls in my project now while i wait for the authors to merge the update TgSharp.TL.zip

On this version i'm having issues while managing the ISessionStore, but the rest is working fine.

Im does not see TLInputPhotoFileLocation in linked repo.

Sellec avatar Aug 10 '20 12:08 Sellec

Im does not see TLInputPhotoFileLocation in linked repo.

https://github.com/aarani/TgSharp/blob/master/src/TgSharp.TL/TL/TLInputPhotoFileLocation.cs

dariooo512 avatar Aug 10 '20 12:08 dariooo512

Im does not see TLInputPhotoFileLocation in linked repo.

https://github.com/aarani/TgSharp/blob/master/src/TgSharp.TL/TL/TLInputPhotoFileLocation.cs

Its interesting...repo search founds nothing https://github.com/aarani/TgSharp/search?q=TLInputPhotoFileLocation&unscoped_q=TLInputPhotoFileLocation

Sellec avatar Aug 10 '20 12:08 Sellec

Hey, dariooo512. Thanks very much! By the way, how did you fixed the namespaces? I am fixing it manually, it is really a massive project. Or could you give me the fixed source code, I want to modify something.

Which IDE are you using? Consider switching to Rider or installing Resharper extension for VS. They come with advanced solution management (fixing namespaces took one click) TgSharp.Core.zip

dariooo512 avatar Aug 10 '20 12:08 dariooo512

Seems like this repo have some serious differences. For example, look into TLChannelDifferenceTooLong - there are no ReadInboxMaxId property.

Sellec avatar Aug 10 '20 12:08 Sellec

Yeah, the repo it's an API upgrade from layer 66 to 108 so you probably will encounter breaking changes.

dariooo512 avatar Aug 10 '20 13:08 dariooo512

Repo is dirty, very dirty...

Yeah, the repo it's an API upgrade from layer 66 to 108 so you probably will encounter breaking changes.

The changes are...terrible, not breaking. For example - TgSharp.Core.TelegramClient.SendUploadedPhoto has missing caption argument, but TLInputMediaUploadedPhoto have Caption property. And nuget versions of TgSharp/TlSharp have this argument.

Sellec avatar Aug 10 '20 13:08 Sellec

Hey, dariooo512. Thanks very much! By the way, how did you fixed the namespaces? I am fixing it manually, it is really a massive project. Or could you give me the fixed source code, I want to modify something.

Which IDE are you using? Consider switching to Rider or installing Resharper extension for VS. They come with advanced solution management (fixing namespaces took one click) TgSharp.Core.zip

I use VS2019 with Resharper extension, but I only know the basic use of the Resharper. How to fix all the Error with one click? Anyway, my problems is solved with the source code you given. Thanks!

Jycjmf avatar Aug 11 '20 02:08 Jycjmf

Yeah, the repo it's an API upgrade from layer 66 to 108 so you probably will encounter breaking changes.

Some strange thing - message entities are not applied to sended messages. I.e. when i use message copying (take message from one channel and resend it to another channel directly with copying text and Entities property), message formatting is not applied. For example, TLMessageEntityBold is not applied. This entity can be in source message (working nice), but it does not work when use it with same length and offset in new message with the same text. Maybe some flags or message properties is missing in my code? This code works with classic TLSharp.

Sellec avatar Aug 14 '20 06:08 Sellec

Yeah, the repo it's an API upgrade from layer 66 to 108 so you probably will encounter breaking changes.

Some strange thing - message entities are not applied to sended messages. I.e. when i use message copying (take message from one channel and resend it to another channel directly with copying text and Entities property), message formatting is not applied. For example, TLMessageEntityBold is not applied. This entity can be in source message (working nice), but it does not work when use it with same length and offset in new message with the same text. Maybe some flags or message properties is missing in my code? This code works with classic TLSharp.

Yes, ComputeFlags method is empty in TLRequestSendMessage. Can it be fixed and recompiled?

Sellec avatar Aug 14 '20 06:08 Sellec

FloodException client.ConnectAsync: Flood prevention. Telegram now requires your program to do requests again only after 5 seconds have passed (TimeToWait property). If you think the culprit of this problem may lie in TLSharp's implementation, open a Github issue please.

FILEREF_UPGRADE_NEEDED

atrdev-rgb avatar Dec 15 '20 02:12 atrdev-rgb

I've managed to found This repo where there's an updated version with this problem solved.

The new code to get it working is

if (!(message.Media is TLMessageMediaPhoto media) || !(media.Photo is TLPhoto photo))
{
     continue;
}

var size = photo.Sizes.OfType<TLPhotoSize>().Last();
 var request = new TLInputPhotoFileLocation
 {
     Id = photo.Id,
     FileReference = photo.FileReference,
     AccessHash = photo.AccessHash,
     ThumbSize = size.Type
};
var buffer = await _client.GetFile(request, 1024 * 512);

I've fixed some namespaces and i'm using those dlls in my project now while i wait for the authors to merge the update TgSharp.TL.zip

On this version i'm having issues while managing the ISessionStore, but the rest is working fine.

please discard a working example, with your example

atrdev-rgb avatar Dec 15 '20 02:12 atrdev-rgb

Any update, im stucking with this too, please help

ralphwald0 avatar Jun 22 '21 09:06 ralphwald0

Yes. I stoped using TLSharp cause it seems dead. Now I'm using TDSharp based on TDLib and it works like a charm.

Please don't hesitate to ask me if you think I can help you in any other way.

Can you please guide me to use TDSharp in webforms

ejazmusavi avatar Oct 12 '21 11:10 ejazmusavi