Td: what is inputFileGenerated?

Created on 5 Mar 2018  路  8Comments  路  Source: tdlib/td

hi every one what is what is inputFileGenerated and what's it usage?

Most helpful comment

It should be used whenever not yet existed file needs to be sent. For example,

  1. A compressed photo, generated from an existing one.
  2. A compressed video, generated from an existing one.
  3. A file, which first needs to be downloaded from an HTTP URL.
  4. A currently recording voice/video note.
  5. A file outside library cache that needs to be copied and stored in the cache.

To achieve that the client specifies two pretty arbitrary strings original_path and conversion and should be able to generate the file based on value of these parameters whenever it receives updateFileGenerationStart.

For example, a client can use for the mentioned cases:

  1. Path to the original photo as original_path and "compress_photo" as conversion.
  2. Path to the original video as original_path and "compress_video" as conversion.
  3. URL of the file as original_path and "download" as conversion.
  4. ".ogg" as original_path and "record_voice" as conversion.
  5. Path to the original file as original_path and "copy" as conversion.

There are a lot of more complex cases when inputFileGenerated can be used. Basically all cases except sending a local/already sent file should be covered by inputFileGenerated.

All 8 comments

It should be used whenever not yet existed file needs to be sent. For example,

  1. A compressed photo, generated from an existing one.
  2. A compressed video, generated from an existing one.
  3. A file, which first needs to be downloaded from an HTTP URL.
  4. A currently recording voice/video note.
  5. A file outside library cache that needs to be copied and stored in the cache.

To achieve that the client specifies two pretty arbitrary strings original_path and conversion and should be able to generate the file based on value of these parameters whenever it receives updateFileGenerationStart.

For example, a client can use for the mentioned cases:

  1. Path to the original photo as original_path and "compress_photo" as conversion.
  2. Path to the original video as original_path and "compress_video" as conversion.
  3. URL of the file as original_path and "download" as conversion.
  4. ".ogg" as original_path and "record_voice" as conversion.
  5. Path to the original file as original_path and "copy" as conversion.

There are a lot of more complex cases when inputFileGenerated can be used. Basically all cases except sending a local/already sent file should be covered by inputFileGenerated.

tanks

is there any list of conversions? Or should dev implement each?

There is no built-in conversions except "#url#" used for files, which need to de downloaded from an HTTP/HTTPS URL. But even that conversion needs to be handled and implemented by the client.

Also, all conversions beginning with '#' are reserved for internal TDLib usage.

How to register conversion so tdlib can know which method to call?

Should I use updateFileGenerationStart and updateFileGenerationStop as wrapper?

You must handle updateFileGenerationStart and updateFileGenerationStop updates from TDLib, and then provide progress about the generation using setFileGenerationProgress and finishFileGeneration.

Since TDLib 1.4.0 you can also use the method writeGeneratedFilePart if you have no direct access to TDLib's file system.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

IRGC picture IRGC  路  4Comments

hatami57 picture hatami57  路  4Comments

RadRussianRus picture RadRussianRus  路  3Comments

mossaudi picture mossaudi  路  3Comments

Losses picture Losses  路  3Comments