Skip to content

optimizeStorage

Sahri Riza Umami edited this page Jul 1, 2018 · 5 revisions

Optimizes storage usage, i.e. deletes some files and returns new storage usage statistics.
Secret thumbnails can't be deleted.

optimizeStorage(size, ttl, count, immunity_delay, file_type, chat_ids, exclude_chat_ids, chat_limit, callback, data)
Field Type Description
size int53 Limit on the total size of files after deletion. Pass -1 to use the default limit.
ttl int32 Limit on the time that has passed since the last time a file was accessed (or creation time for some filesystems). Pass -1 to use the default limit.
count int32 Limit on the total count of files after deletion. Pass -1 to use the default limit.
immunity_delay int32 The amount of time after the creation of a file during which it can't be deleted, in seconds. Pass -1 to use the default value.
file_types vector If not empty, only files with the given type(s) are considered. By default, all types except thumbnails, profile photos, stickers and wallpapers are deleted.
chat_ids vector If not empty, only files from the given chats are considered. Use 0 as chat identifier to delete files not belonging to any chat (e.g., profile photos).
exclude_chat_ids vector If not empty, files from the given chats are excluded. Use 0 as chat identifier to exclude all files not belonging to any chat (e.g., profile photos).
chat_limit int32 Same as in getStorageStatistics. Affects only returned statistics.

Example

  • Optimizes storage usage using default value.

    optimizeStorage()

    Response:

    {
      ["@type"] = "storageStatistics",
      by_chat = {
        {
          ["@type"] = "storageStatisticsByChat",
          by_file_type = {
            {
              ["@type"] = "storageStatisticsByFileType",
              count = 1,
              file_type = {
                ["@type"] = "fileTypeThumbnail"
              },
              size = 3958
            },
            {
              ["@type"] = "storageStatisticsByFileType",
              count = 1,
              file_type = {
                ["@type"] = "fileTypeDocument"
              },
              size = 1027
            }
          },
          chat_id = 0,
          count = 2,
          size = 4985
        }
      },
      count = 2,
      size = 4985
    }

Frequently Asked Questions
The Functions

Clone this wiki locally