Telethon/methods/upload/get_file.html
2024-09-23 18:48:46 +02:00

34 lines
5.2 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>GetFileRequest</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link id="style" href="../../css/docs.dark.css" rel="stylesheet">
<script>
document.getElementById("style").href = "../../css/docs."
+ (localStorage.getItem("theme") || "light")
+ ".css";
</script>
<link href="https://fonts.googleapis.com/css?family=Nunito|Source+Code+Pro"
rel="stylesheet">
</head>
<body>
<div id="main_div"><ul class="horizontal"><li><a href="../../index.html">API</a></li><img src="../../img/arrow.svg" alt="/" /><li><a href="../index.html">Methods</a></li><img src="../../img/arrow.svg" alt="/" /><li><a href="index.html">Upload</a></li><img src="../../img/arrow.svg" alt="/" /><li><a href="get_file.html">GetFileRequest</a></li></ul><h1>GetFileRequest</h1><p><strong>Both users and bots</strong> can use this request. <a href="#examples">See code examples.</a></p><pre>---functions---
upload.getFile#be5335be flags:# precise:flags.0?<a href="../../index.html#true">true</a> cdn_supported:flags.1?<a href="../../index.html#true">true</a> location:<a href="../../types/input_file_location.html">InputFileLocation</a> offset:<a href="../../index.html#long">long</a> limit:<a href="../../index.html#int">int</a> = <a href="../../types/upload/file.html">upload.File</a></pre><button onclick="cp('from telethon.tl.functions.upload import GetFileRequest');">Copy import to the clipboard</button><h3>Returns</h3><table><tr><td><a href="../../types/upload/file.html">upload.File</a></td></tr></table><p>This type can be an instance of either:</p><table><tr><td><a href="../../constructors/upload/file.html">File</a></td><td><a href="../../constructors/upload/file_cdn_redirect.html">FileCdnRedirect</a></td></tr></table><h3>Parameters</h3><table><tr><td><b>location</b></td><td style="text-align:center"><a href="../../types/input_file_location.html">InputFileLocation</a></td><td></td></tr><tr><td><b>offset</b></td><td style="text-align:center"><a href="../../index.html#long">long</a></td><td></td></tr><tr><td><b>limit</b></td><td style="text-align:center"><a href="../../index.html#int">int</a></td><td></td></tr><tr><td><b>precise</b></td><td style="text-align:center"><a href="../../index.html#true">flag</a></td><td>This argument defaults to <code>None</code> and can be omitted.</td></tr><tr><td><b>cdn_supported</b></td><td style="text-align:center"><a href="../../index.html#true">flag</a></td><td>This argument defaults to <code>None</code> and can be omitted.</td></tr></table><h1>Known RPC errors</h1><p>This request can cause 7 known errors:</p><table><tr><td><code>AuthKeyPermEmptyError</code></td><td>The method is unavailable for temporary authorization key, not bound to permanent.</td></tr><tr><td><code>FileIdInvalidError</code></td><td>The provided file id is invalid. Make sure all parameters are present, have the correct type and are not empty (ID, access hash, file reference, thumb size ...).</td></tr><tr><td><code>InputFetchFailError</code></td><td>Failed deserializing TL payload.</td></tr><tr><td><code>LimitInvalidError</code></td><td>An invalid limit was provided. See https://core.telegram.org/api/files#downloading-files.</td></tr><tr><td><code>LocationInvalidError</code></td><td>The location given for a file was invalid. See https://core.telegram.org/api/files#downloading-files.</td></tr><tr><td><code>OffsetInvalidError</code></td><td>The given offset was invalid, it must be divisible by 1KB. See https://core.telegram.org/api/files#downloading-files.</td></tr><tr><td><code>TimeoutError</code></td><td>A timeout occurred while fetching data from the worker.</td></tr></table><p>You can import these from <code>telethon.errors</code>.</p><h1 id="examples">Example</h1><p>Please refer to the documentation of <a href="https://docs.telethon.dev/en/stable/modules/client.html#telethon.client.downloads.DownloadMethods.download_media"><code>client.download_media()</code></a> to learn about the parameters and see several code examples on how to use it.</p><p>The method above is the recommended way to do it. If you need more control over the parameters or want to learn how it is implemented, open the details by clicking on the "Details" text.</p><details><pre><strong>from</strong> telethon.sync <strong>import</strong> TelegramClient
<strong>from</strong> telethon <strong>import</strong> functions, types
<strong>with</strong> TelegramClient(name, api_id, api_hash) <strong>as</strong> client:
result = client(functions.upload.GetFileRequest(
location=types.InputFileLocation(
volume_id=-12398745604826,
local_id=42,
secret=-12398745604826,
file_reference=<em>b'arbitrary\x7f data \xfa here'</em>
),
offset=-12398745604826,
limit=100,
precise=<strong>True</strong>,
cdn_supported=<strong>True</strong>
))
print(result.stringify())</pre></details><textarea id="c" class="invisible"></textarea><script>function cp(t){var c=document.getElementById("c");c.value=t;c.select();try{document.execCommand("copy")}catch(e){}}</script></div><script>prependPath = "../../";</script><script src="../../js/search.js"></script></body></html>