<p>When working with the API, it is sometimes necessary to send a relatively large file to the server. For example, when sending a message with a photo/video attachment or when setting the current user's profile picture.</p>
<p>The file's binary content is then split into parts. All parts must have the same size (<strong>part_size</strong>) and the following conditions must be met:</p>
<p>The following <ahref="/api/config#client-configuration">appConfig fields</a> specify the maximum number of uploadable file parts: </p>
<ul>
<li><ahref="/api/config#upload-max-fileparts-default">upload_max_fileparts_default »</a> - Maximum number of file parts uploadable by non-Premium users. </li>
<li><ahref="/api/config#upload-max-fileparts-premium">upload_max_fileparts_premium »</a> - Maximum number of file parts uploadable by Premium users. </li>
</ul>
<p>Note that the limit of uploadable file parts does not account for the <strong>part_size</strong>: thus the total file size limit can only be reached with the biggest possible <strong>part_size</strong> of 512KB, which is actually the recommended <strong>part_size</strong> to avoid excessive protocol overhead. </p>
<p>Each part should have a sequence number, <strong>file_part</strong>, with a value ranging from 0 to the value of the appropriate config parameter minus 1. </p>
<p>After the file has been partitioned you need to choose a method for saving it on the server. Use <ahref="/method/upload.saveBigFilePart">upload.saveBigFilePart</a> in case the full size of the file is more than <strong>10 MB</strong> and <ahref="/method/upload.saveFilePart">upload.saveFilePart</a> for smaller files.</p>
<p>Each call saves a portion of the data in a temporary location on the server to be used later. The storage life of each portion of data is between several minutes and several hours (depending on how busy the storage area is). After this time, the file part will become unavailable. </p>
<p>To increase the time efficiency of a file save operation, we recommend using a (local, i.e. <strong>not</strong> with invokeAfterMsgs) call queue, so X pieces of the file are being saved at any given moment in time. Each successful operation to save a part invokes the method call to save the next part. The value of X can be tuned to achieve maximum performance.</p>
<p>To further increase performance, multiple parallel call queues (i.e. a tunable number Y of queues) linked to separate TCP connections to the datacenters can be used to upload multiple chunks in parallel. </p>
<p>When using one of the methods mentioned above to save file parts, one of the following <ahref="/api/errors#400-bad-request">data input errors</a> may be returned:</p>
<li>FLOOD_PREMIUM_WAIT_X: Indicates that upload speed is limited because the current account does not have a <ahref="/api/premium">Premium</a> subscription, and that the query must be automatically repeated by the client after X seconds.<br>
When receiving this error, clients should display the <ahref="/api/premium">Telegram Premium subscription modal</a>, offering the user to purchase a Premium subscription to increase upload speed <ahref="/api/config#upload-premium-speedup-upload">upload_premium_speedup_upload»</a> times.<br>
Note that this modal should only be displayed if the file that is being uploaded is currently visible to the user; if it isn't, the modal should be displayed once the loading/already loaded media becomes visible.<br>
Also, this modal should only be shown <strong>at most</strong> every <ahref="/api/config#upload-premium-speedup-notify-period">upload_premium_speedup_notify_period»</a>, to avoid bombarding the user with this popup for every file whose upload is slowed down.<br>
This error can only be received when the user has uploaded tens of gigabytes or more. </li>
<p>While the parts are being uploaded, an <ahref="https://en.wikipedia.org/wiki/MD5">MD5 hash</a> of the file contents can also be computed to be used later as the <strong>md5_checksum</strong> parameter in the <ahref="/constructor/inputFile">inputFile</a> constructor (since it is checked only by the server, for encrypted secret chat files it must be generated from the encrypted file).<br>
After the entire file is successfully saved, the final method may be called and passed the generated <ahref="/type/InputFile">inputFile</a> object. In case the <ahref="/method/upload.saveBigFilePart">upload.saveBigFilePart</a> method is used, the <ahref="/constructor/inputFileBig">inputFileBig</a> constructor must be passed, in other cases use <ahref="/constructor/inputFile">inputFile</a>.</p>
<ul>
<li><ahref="/method/messages.sendMedia">messages.sendMedia</a> - Sends a media file to a chat</li>
<li><ahref="/method/messages.uploadMedia">messages.uploadMedia</a> - Uploads a media file to a chat, without sending it, returning only a <ahref="/type/MessageMedia">MessageMedia</a> constructor that can be used to later send the file to multiple chats, without reuploading it every time. </li>
<li><ahref="/method/photos.uploadProfilePhoto">photos.uploadProfilePhoto</a> - Used to set a <ahref="#uploading-profile-or-chat-pictures">profile or chat picture or video</a></li>
</ul>
<p>The file save operation may return one of the following <ahref="/api/errors#400-bad-request">data input errors</a>:</p>
<p>Use <ahref="/method/messages.editMessage">messages.editMessage</a> to edit or replace a media file sent using <ahref="/method/messages.sendMedia">messages.sendMedia</a> and <ahref="/method/messages.sendMultiMedia">messages.sendMultiMedia</a>. </p>
<p>If one wishes to edit only the <code>spoiler</code>, <code>ttl_seconds</code> or <code>query</code> attributes of the media, this may be done without reuploading the entire media file, by simply passing the old media to the <code>id</code> parameter of <ahref="/constructor/inputMediaPhoto">inputMediaPhoto</a>, <ahref="/constructor/inputMediaDocument">inputMediaDocument</a> and updating the values of the <code>spoiler</code>/<code>ttl_seconds</code>/<code>query</code> attributes as needed. </p>
<p>If one wishes to edit any other attribute (for example, the file name specified in <ahref="/constructor/documentAttributeFilename">documentAttributeFilename</a>, any other <ahref="/type/DocumentAttribute">DocumentAttribute</a> or any flag different from <code>spoiler</code>/<code>ttl_seconds</code>/<code>query</code>) <strong>a full reupload of the file is required</strong>, in order to be able to specify the new attributes in <ahref="/constructor/inputMediaUploadedPhoto">inputMediaUploadedPhoto</a>/<ahref="/constructor/inputMediaUploadedDocument">inputMediaUploadedDocument</a>. </p>
<p>The only exception to this rule is when editing the <ahref="/constructor/documentAttributeVideo">documentAttributeVideo</a>.<code>video_start_ts</code> attribute of video <ahref="/api/stories">stories</a>, in which case <ahref="/constructor/inputMediaDocument">inputMediaDocument</a> may still be used with <ahref="/constructor/inputFileStoryDocument">inputFileStoryDocument</a> instead of <ahref="/constructor/inputFile">inputFile</a> without reuploading the entire story video, see <ahref="/api/stories#editing-stories">here»</a> for more info on the full flow.</p>
<p>The API also supports streamed uploads, in cases where the length of the file is not known before starting the upload. </p>
<p>This is useful for example when converting a video, to avoid buffering the entire converted video on the filesystem, each part is uploaded immediately as soon as it is produced by the encoder. </p>
<p>Everything works similarly to <ahref="#uploading-files">normal uploads</a>, with a few key differences:</p>
<ul>
<li>The client buffers <code>part_size</code> bytes (or less if the stream ends) before immediately uploading the part as described <ahref="#uploading-files">in the previous section</a>.</li>
<li>A <code>total_stream_size</code> variable must be used to keep track of the total number of bytes read from the stream.</li>
<li><ahref="/method/upload.saveBigFilePart">upload.saveBigFilePart</a> must always be used, even if the stream turns out to be smaller than 10MB. </li>
<li>The <code>file_total_parts</code> field must be set to <code>-1</code> for all parts except for the last one, using the following logic:<ul>
<li>If the stream ends and the length of the buffered part is bigger than 0, upload it, setting <code>file_total_parts=ceil(total_stream_size/part_size)</code> (like for normal uploads)</li>
<li>If the stream ends and the length of the buffered part is equal to 0, upload it anyway (upload one last empty part), setting <code>file_total_parts=ceil(total_stream_size/part_size)</code> (like for normal uploads)</li>
</ul>
</li>
</ul>
<p>Note that streamed uploads cannot be used when uploading photos with <ahref="/constructor/inputMediaUploadedPhoto">inputMediaUploadedPhoto</a>. </p>
<p>Telegram allows grouping photos into <ahref="https://telegram.org/blog/albums-saved-messages">albums</a> and generic files (audio, docuemnts) into media groups. </p>
<p>To do this, <ahref="/method/messages.sendMultiMedia">messages.sendMultiMedia</a> is used, wrapping each <ahref="/type/InputMedia">InputMedia</a> constructor (uploaded or pre-existing, maximum 10 per media group) into an <ahref="/constructor/inputSingleMedia">inputSingleMedia</a> constructor, optionally providing a custom per-file caption in <code>message</code>. </p>
<p>For photo albums, clients should display an album caption only if exactly one photo in the group has a caption, otherwise no album caption should be displayed, and only when viewing in detail a specific photo of the group the caption should be shown.<br>
Other grouped media can display a caption under each file. </p>
<p>For some types of documents like GIFs, <ahref="/method/messages.getDocumentByHash">messages.getDocumentByHash</a> can be used to search for the document on Telegram servers.
The SHA256 hash of the file is computed, and it is passed along with the file's mime type and size to the method: if the file type is correct and the file is found, a <ahref="/constructor/document">document</a> is returned.</p>
<h3><aclass="anchor"href="#uploading-profile-or-chat-pictures"id="uploading-profile-or-chat-pictures"name="uploading-profile-or-chat-pictures"><iclass="anchor-icon"></i></a>Uploading profile or chat pictures</h3>
<p>User profile pictures can be uploaded using the <ahref="/method/photos.updateProfilePhoto">photos.uploadProfilePhoto</a> method: the actual profile picture has to be <ahref="#uploading-files">uploaded as for normal files</a>.<br>
<ahref="/method/photos.updateProfilePhoto">photos.uploadProfilePhoto</a> can also be used to reupload previously uploaded profile pictures. </p>
<p>The optional <code>bot</code> flag can contain info of a <ahref="/api/bots">bot</a> we own, to change the profile photo of that bot, instead of the current user.</p>
<p>Animated profile pictures are also supported, by populating the <code>video</code> flag: square MPEG4 videos up to <code>1080x1080</code> are supported, <code>800x800</code> is the recommended resolution.<br>
The <code>video_start_ts</code> is a floating point UNIX timestamp in seconds, indicating the frame of the video that should be used as static preview. </p>
<p><ahref="/api/channel">Chat, channel and supergroup</a> profile photos and videos can be uploaded using <ahref="/method/messages.editChatPhoto">messages.editChatPhoto</a> (<ahref="/api/channel#basic-groups">basic groups</a>) or <ahref="/method/channels.editPhoto">channels.editPhoto</a> (<ahref="/api/channel">channels, supergroups</a>).<br>
<p><ahref="/api/stickers">Sticker</a> and <ahref="/api/custom-emoji">custom emoji sticker</a>-based profile pictures are also supported, by populating the <code>video_emoji_markup</code> flag with either a <ahref="/constructor/videoSizeStickerMarkup">videoSizeStickerMarkup</a> or a <ahref="/constructor/videoSizeEmojiMarkup">videoSizeEmojiMarkup</a> constructor. </p>
<p>The profile picture should be rendered by placing the sticker at the center of a square canvas, in such a way that it occupies at most 67% of it. The background of the canvas is generated from <code>background_colors</code>, which contains a vector of 1, 2, 3 or 4 RBG-24 colors used to generate a solid (1), gradient (2) or freeform gradient (3, 4) background, similar to how <ahref="/api/wallpapers#fill-types">fill wallpapers</a> are generated. The rotation angle for gradient backgrounds is 0.<br>
If animated or video stickers/custom emojis are used, the <code>video_start_ts</code> flag can contain a floating point UNIX timestamp in seconds, indicating the frame of the profile picture that should be used as static preview. </p>
<p><ahref="/method/account.getDefaultProfilePhotoEmojis">account.getDefaultProfilePhotoEmojis</a> may be used to fetch a list of suggested <ahref="/api/custom-emoji">custom emojis</a> that can be used as profile pictures even by non-premium accounts; <ahref="/method/account.getDefaultGroupPhotoEmojis">account.getDefaultGroupPhotoEmojis</a> is the counterpart for group profile pictures.</p>
<p>The custom emoji selection UI should offer a list of categories to quickly filter results by a (list of) emojis, or by some other criteria, see <ahref="/api/emoji-categories">here»</a> for more info. </p>
<p>There are methods available to download files which have been successfully uploaded. The schema of the types and methods used is presented below:</p>
<li><code>thumb_size</code> taken from the <code>type</code> field of the desired <ahref="/type/PhotoSize">PhotoSize</a>/<ahref="/type/VideoSize">VideoSize</a> of the <ahref="/constructor/photo">photo</a></li>
<p>For profile pictures of users, channels, supergroups and groups, <ahref="/constructor/inputPeerPhotoFileLocation">inputPeerPhotoFileLocation</a> has to be used:</p>
<ul>
<li><code>peer</code> is the identifier of the peer whose photo we want to download</li>
<li><code>big</code> is used to choose whether to download the full-resolution picture, or just the thumbnail</li>
<li><code>photo_id</code> is extracted from the <ahref="/constructor/chatPhoto">chatPhoto</a> or <ahref="/constructor/userProfilePhoto">userProfilePhoto</a> of the desired profile photo</li>
</ul>
</li>
<li>
<p>For documents, <ahref="/constructor/inputDocumentFileLocation">inputDocumentFileLocation</a> is used:</p>
<ul>
<li><code>id</code>, <code>file_reference</code> and <code>access_hash</code> taken from the <ahref="/constructor/document">document</a> constructor</li>
<li>If downloading the thumbnail of a document or a <ahref="/api/stickers#premium-animated-sticker-effects">premium sticker effect</a>, <code>thumb_size</code> should be taken from the <code>type</code> field of the desired <ahref="/type/PhotoSize">PhotoSize</a>/<ahref="/type/VideoSize">VideoSize</a> of the <ahref="/constructor/photo">photo</a>; otherwise, provide an empty string.</li>
<p>For previews of sticker sets, <ahref="/constructor/inputStickerSetThumb">inputStickerSetThumb</a> is used (note: to download stickers and previews of stickers use the document method described above for documents):</p>
<ul>
<li><code>stickerset</code> is set to the <ahref="/type/InputStickerSet">InputStickerSet</a> constructor generated from <ahref="/constructor/stickerSet">stickerSet</a></li>
<li><code>thumb_version</code> is copied from the same field in <ahref="/constructor/stickerSet">stickerSet</a></li>
</ul>
</li>
<li>
<p>For encrypted secret chat and telegram passport documents, respectively <ahref="/constructor/inputEncryptedFileLocation">inputEncryptedFileLocation</a> and <ahref="/constructor/inputSecureFileLocation">inputSecureFileLocation</a> have to be used, with parameters extracted from <ahref="/constructor/encryptedFile">encryptedFile</a> and <ahref="/constructor/secureFile">secureFile</a> (<ahref="/passport">passport docs</a>).</p>
</li>
<li>
<p>For livestream chunks, <ahref="/constructor/inputGroupCallStream">inputGroupCallStream</a> is used:</p>
<ul>
<li><code>call</code> contains the related group call ID+access hash, taken from the <ahref="/constructor/groupCall">groupCall</a> constructor.</li>
<li><code>time_ms</code> specifies the timestamp to fetch</li>
<li><code>scale</code> specifies the duration of the video segment to fetch in milliseconds, by bitshifting <code>1000</code> to the right <code>scale</code> times: <code>duration_ms := 1000 >> scale</code></li>
<li><code>video_channel</code> specifies the video channel to fetch</li>
<li><code>video_quality</code> specifies the selected video quality (0 = lowest, 1 = medium, 2 = best)</li>
<p>For old <strong>deprecated</strong> photos, if the client has cached some old fileLocations with the <strong>deprecated</strong><code>secret</code> identifier, <ahref="/constructor/inputFileLocation">inputFileLocation</a> or <ahref="/constructor/inputPhotoLegacyFileLocation">inputPhotoLegacyFileLocation</a> is used (this is mainly used for backwards compatibility with bot API file IDs, all user clients must use the modern <ahref="/constructor/inputPhotoFileLocation">inputPhotoFileLocation</a> file IDs): </p>
<li>All fields are taken from the previously cached fileLocation except for <code>file_reference</code>, <code>access_hash</code> and <code>id</code>, which are taken from the <ahref="/constructor/photo">photo</a> constructor (the last two fields are used only if available, in which case <ahref="/constructor/inputPhotoLegacyFileLocation">inputPhotoLegacyFileLocation</a> is used instead of <ahref="/constructor/inputFileLocation">inputFileLocation</a>).</li>
</ul>
</li>
</ul>
<p>The size of each file in bytes is available, which makes it possible to download the file in parts using the parameters <strong>offset</strong> and <strong>limit</strong>, similar to the way files are uploaded.</p>
<p>If <strong>precise</strong> flag is not specified, then </p>
<ul>
<li>The parameter <strong>offset</strong> must be divisible by 4 KB.</li>
<li>The parameter <strong>limit</strong> must be divisible by 4 KB.</li>
<li>1048576 (1 MB) must be divisible by <strong>limit</strong>.</li>
</ul>
<p>If <strong>precise</strong> is specified, then</p>
<ul>
<li>The parameter <strong>offset</strong> must be divisible by 1 KB.</li>
<li>The parameter <strong>limit</strong> must be divisible by 1 KB.</li>
<li><strong>limit</strong> must not exceed 1048576 (1 MB).</li>
</ul>
<p>In any case the requested part should be within one 1 MB chunk from the beginning of the file, i. e.</p>
<p>When downloading multiple files in parallel from the same DC, clients should limit the parallelism to download at most <code>small_queue_max_active_operations_count</code>/<code>large_queue_max_active_operations_count</code> files in parallel when downloading files smaller/bigger than 20MB (<ahref="/api/config#client-configuration">client configuration parameters»</a>). </p>
<p>The file download operation may return a <code>FILE_REFERENCE_EXPIRED</code> error (or another error starting with <code>FILE_REFERENCE_</code>): in this case, the <code>file_reference</code> field of the input location must be <ahref="/api/file_reference">refreshed</a>.
The file download operation may return an <ahref="/constructor/upload.fileCdnRedirect">upload.fileCdnRedirect</a> constructor: in this case, <ahref="/cdn">these</a> instructions must be followed for downloading CDN files.
The file download operation may also return one of the following <ahref="/api/errors#400-bad-request">data input errors</a>:</p>
<ul>
<li>FILE_ID_INVALID: The file address is invalid</li>
<li>OFFSET_INVALID: The <strong>offset</strong> value is invalid</li>
<li>LIMIT_INVALID: The <strong>limit</strong> value is invalid</li>
<li>FILE_MIGRATE_X: The file is in the datacenter No. X</li>
<li>FLOOD_WAIT_X: Repeat the query after X seconds</li>
<li>FLOOD_PREMIUM_WAIT_X: Indicates that download speed is limited because the current account does not have a <ahref="/api/premium">Premium</a> subscription, and that the query must be automatically repeated by the client after X seconds.<br>
When receiving this error, clients should display the <ahref="/api/premium">Telegram Premium subscription modal</a>, offering the user to purchase a Premium subscription to increase download speed <ahref="/api/config#upload-premium-speedup-download">upload_premium_speedup_download»</a> times.<br>
Note that this modal should only be displayed if the file that is being downloaded is currently visible to the user; if it isn't, the modal should be displayed once the loading/already loaded media becomes visible.<br>
Also, this modal should only be shown <strong>at most</strong> every <ahref="/api/config#upload-premium-speedup-notify-period">upload_premium_speedup_notify_period»</a>, to avoid bombarding the user with this popup for every file whose download is slowed down.<br>
This error can only be received when the user has uploaded tens of gigabytes or more. </li>
<p>In order to confirm the integrity of the downloaded file, clients are recommended to verify hashes for each downloaded part, as for <ahref="/cdn">CDN DCs</a>.
<ahref="/method/upload.getFileHashes">upload.getFileHashes</a> contain <ahref="/type/FileHash">FileHash</a> constructors. Each of these constructors contains the SHA-256 hash of a part of the file that starts with <code>offset</code> and takes <code>limit</code> bytes.</p>
<p>Before saving each portion of the data received from the DC into the file, the client can confirm that its hash matches the hash that was received from the master DC. If missing a hash for any file part, client developers must use the <ahref="/method/upload.getFileHashes">upload.getFileHashes</a> method to obtain the missing hash.</p>
<h4><aclass="anchor"href="#handling-audio-video-and-vector-previews"id="handling-audio-video-and-vector-previews"name="handling-audio-video-and-vector-previews"><iclass="anchor-icon"></i></a>Handling audio, video and vector previews</h4>
<p>A <ahref="/constructor/photoStrippedSize">photoStrippedSize</a> (with type <code>i</code>) is an extremely low-res thumbnail, embedded directly inside media location objects.<br>
It should be shown to the user in chat message previews, or while still downloading the most appropriately sized <ahref="/constructor/photoSize">photoSize</a> through the media DCs as <ahref="#downloading-files">described above</a>. </p>
<p>The stripped <code>bytes</code> payload should be inflated to a JPG payload as seen <ahref="https://github.com/telegramdesktop/tdesktop/blob/1757dd856b84d23f83d4e562c94dde825f6eb40c/Telegram/SourceFiles/ui/image/image.cpp#L43">here»</a>.</p>
<p>Messages with <ahref="/api/stickers#animated-stickers">animated</a>, <ahref="/api/stickers#video-stickers">video</a>, <ahref="/api/stickers#static-stickers">static</a> stickers can have a compressed svg (< 300 bytes) to show the outline of the sticker before fetching the actual sticker.
Sticker outlines will have a <code>j</code> type <ahref="/constructor/photoPathSize">photoPathSize</a> thumbnail. </p>
<p>This specific vector thumbnail consists of an <ahref="https://developer.mozilla.org/en-US/docs/Web/SVG/Tutorial/Paths">SVG path</a>, specially encoded to save space.<br>
<p><code>path</code> will contain the actual SVG path that can be directly inserted in the <code>d</code> attribute of an <ahref="https://developer.mozilla.org/en-US/docs/Web/SVG/Element/path">svg <path> element</a>: </p>
<p>A <ahref="/constructor/videoSize">videoSize</a> constructor is typically used for <ahref="#animated-profile-pictures">animated profile pictures</a>, video previews and <ahref="/api/stickers#premium-animated-sticker-effects">premium sticker effects»</a>.</p>
<p>Remote HTTP files sent by inline bots <ahref="/type/BotInlineResult">in response to inline queries</a> and in other places are represented by <ahref="/type/WebDocument">WebDocument</a> constructors.
When forwarding such remote HTTP files, they should be sent using <ahref="/type/InputMedia">external InputMedia constructors</a>.
Remote HTTP files can only be downloaded directly by the client if contained in a <ahref="/constructor/webDocumentNoProxy">webDocumentNoProxy</a> constructor: in this case, the file is deemed safe to download (this is the case for HTTPS files from certain trusted domains).</p>
<p>However, if the remote file is contained in a <ahref="/constructor/webDocument">webDocument</a>, to avoid leaking sensitive information the file must be downloaded through telegram's servers.
This can be done in a manner similar to <ahref="#downloading-files">normal files</a>, with the difference that <ahref="/method/upload.getWebFile">upload.getWebFile</a> must be used, instead. </p>
<p>The <ahref="/method/upload.getWebFile">upload.getWebFile</a> method is also used to generate preview pictures for maps and download music file covers, as follows. </p>
<p><strong>Note</strong>: the <ahref="/method/upload.getWebFile">upload.getWebFile</a> query must be sent to the DC specified in the <code>webfile_dc_id</code><ahref="/api/config#mtproto-configuration">MTProto configuration field</a>. </p>
<li><ahref="/constructor/inputWebFileLocation">inputWebFileLocation</a> is simply generated by taking the <code>url</code> and <code>access_hash</code> fields of the <ahref="/constructor/webDocument">webDocument</a> constructor.</li>
<li><ahref="/constructor/inputWebFileGeoPointLocation">inputWebFileGeoPointLocation</a> is used to download a server-generated image with the map preview from a <ahref="/constructor/geoPoint">geoPoint</a>.<ul>
<li><code>geo_point</code> is generated from the <code>lat</code>, <code>long</code><code>accuracy_radius</code> parameters of the <ahref="/constructor/geoPoint">geoPoint</a></li>
<li><code>access_hash</code> is the access hash of the <ahref="/constructor/geoPoint">geoPoint</a></li>
<li><code>w</code> - Map width in pixels before applying scale; 16-1024</li>
<li><code>h</code> - Map height in pixels before applying scale; 16-1024</li>
<li><ahref="/constructor/inputWebFileAudioAlbumThumbLocation">inputWebFileAudioAlbumThumbLocation</a> is used to download an album cover with <code>600x600</code> resolution for any music file missing embedded album art.
Note that the <code>document</code> field containing the music file must NOT be provided in secret chats: the locally extracted <code>title</code> and <code>performer</code> fields should be provided, instead.<br>
In normal chats <code>document</code> should always be provided instead of <code>title</code> and <code>performer</code>, as it has more lax flood limits. <ul>
<li><code>small</code> if set, downloads a <code>100x100</code> thumbnail instead.</li>
<li><code>document</code> contains the music file: MUST NOT be provided in secret chats.</li>
<li><code>title</code> contains the song title: should only be provided in secret chats.</li>
<li><code>performer</code> contains the song performer: should only be provided in secret chats.</li>
<p>It is recommended that large queries (<ahref="/method/upload.getFile">upload.getFile</a>, <ahref="/method/upload.saveFilePart">upload.saveFilePart</a>, <ahref="/method/upload.getWebFile">upload.getWebFile</a>) be handled through one or more separate sessions and separate connections, in which no methods other than these should be executed.<br>
This way, data transfer will cause less interference with <ahref="/api/updates">getting updates</a> and other method calls.<br>
If a media DC with the required DC ID is available (<ahref="/constructor/dcOption">dcOption</a> will have the <code>media</code> flag set), queries must be sent to that DC. </p>