xref: /curl/docs/cmdline-opts/max-filesize.md (revision d41916c4)
1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3SPDX-License-Identifier: curl
4Long: max-filesize
5Arg: <bytes>
6Help: Maximum file size to download
7Protocols: FTP HTTP MQTT
8Category: connection
9Added: 7.10.8
10Multi: single
11See-also:
12  - limit-rate
13Example:
14  - --max-filesize 100K $URL
15---
16
17# `--max-filesize`
18
19When set to a non-zero value, it specifies the maximum size (in bytes) of a
20file to download. If the file requested is larger than this value, the
21transfer does not start and curl returns with exit code 63.
22
23Setting the maximum value to zero disables the limit.
24
25A size modifier may be used. For example, Appending 'k' or 'K' counts the
26number as kilobytes, 'm' or 'M' makes it megabytes, while 'g' or 'G' makes it
27gigabytes. Examples: 200K, 3m and 1G. (Added in 7.58.0)
28
29**NOTE**: before curl 8.4.0, when the file size is not known prior to
30download, for such files this option has no effect even if the file transfer
31ends up being larger than this given limit.
32
33Starting with curl 8.4.0, this option aborts the transfer if it reaches the
34threshold during transfer.
35