TDLib: Download a file without saving to disk
Asked Answered
T

0

6

I am using TDLib to implement my custom Telegram client in C#. When initializing the library, I have to set the folder for the telegram cache files and local databases. Whenever I download a photo with TdApi.DownloadFile, it is saved in that folder, presumably for caching.

Is it possible to disable this, and only receive the file in-memory, as either a Stream or a byte[]?

I understand the benefits of caching, but for security (and storage space) reasons that are specific to my application, I want to completely avoid any caching in the filesystem. I am wiling to sacrifice performance and loading speeds.

There are two possible solutions that I can think of. I could write code that automatically clears the download cache folders on app shutdown and startup, or I could somehow implement what the official desktop client does, and store the cached files in an encrypted format. The first solution is not very good when it comes to security, and I don't know how to implement the second one. So it would be best to just disable the caching.

Is this possible, and if so, how?

Thereafter answered 21/2, 2020 at 17:1 Comment(2)
Hi, did you find a solution for your problem?Comprehension
@AttilaSzász Unfortunately no, I gave up on that project. Looking back at this, my best advice is to reverse-engineer and re-implement that TdApi.DownloadFile method (with your favorite decompiler), and move the bytes yourself without caching to disk.Pourparler

© 2022 - 2024 — McMap. All rights reserved.