Skip to main content

funget

HTTP 文件传输工具,提供单线程下载、Range 并发下载、断点续传和 PUT/POST 上传。 核心由 Rust 实现,同时提供 Python 库和独立命令行二进制两种用法。

安装

作为 Python 库

pip install funget

需要 Python 3.12 或更高版本。无任何运行时依赖,各平台提供预编译 wheel, 安装时不需要 Rust 工具链。

只要命令行

命令行是独立的原生二进制,不需要 Python 环境。从 Releases 下载对应平台的文件即可:

curl -L https://github.com/farfarfun/funget/releases/latest/download/funget-x86_64-unknown-linux-gnu -o funget
chmod +x funget && sudo mv funget /usr/local/bin/

pip install funget 同样会提供 funget 命令,与独立二进制共用同一套实现。

命令行

funget download https://httpbin.org/bytes/1024 -o file.bin
funget download https://httpbin.org/bytes/1024 --worker 8 --block-size 50
funget download https://httpbin.org/bytes/1024 -o file.bin --resume   # 中断后重跑继续
funget upload ./file.bin https://httpbin.org/put
funget info https://httpbin.org/bytes/1024

运行 funget --help 或 funget <command> --help 查看完整参数。

Python API

download() 会先检查文件大小和 Range 支持:超过 10 MiB 且服务器支持 Range 时并发下载,否则使用单线程。

from funget import download

ok = download(
    "https://httpbin.org/bytes/1024",
    "./downloads/file.bin",
    overwrite=True,
)

也可以显式选择下载方式:

from funget import multi_thread_download, simple_download

simple_download(
    "https://httpbin.org/bytes/1024", "./downloads/small.bin", chunk_size=64 * 1024
)
multi_thread_download(
    "https://httpbin.org/bytes/1024",
    "./downloads/large.bin",
    worker_num=8,
    block_size=50,
)

上传支持 PUT 和 multipart POST:

from pathlib import Path
from tempfile import TemporaryDirectory

from funget import single_upload

with TemporaryDirectory() as directory:
    filepath = Path(directory) / "example-upload.txt"
    filepath.write_text("funget upload example\n", encoding="utf-8")

    single_upload("https://httpbin.org/put", str(filepath), method="PUT")
    single_upload("https://httpbin.org/post", str(filepath), method="POST")

该示例使用公开测试服务,运行时需要网络连接。生产环境请使用接受相应 PUT 或 multipart POST 请求的上传地址。

断点续传

传 resume=True 后,中断的下载在下次调用时从断点继续,单线程和并发两条路径都支持:

from funget import download

download("https://example.com/huge.iso", "./huge.iso", resume=True)

续传期间会在目标文件旁维护 huge.iso.funget.json 状态文件,下载成功后自动删除。 远端文件若发生变化(ETag、Last-Modified 或大小不匹配),续传状态会被丢弃并重新下载, 不会拼出一个损坏的文件。默认关闭,不开启时行为与旧版完全一致。

参数

所有公开 API 均返回 bool,不抛异常。常用参数:

参数 单位 说明
worker_num 个 并发下载的分块并发数
block_size MiB 多线程下载分块大小
chunk_size 字节 单线程下载或上传读取块大小
max_retries 次 失败后的最大重试次数,退避 2^n 秒
timeout 秒 单次读取超时(不是整体下载超时)
headers - 自定义 HTTP 请求头
auth - (用户名, 密码) 二元组,走 Basic 认证
resume - 是否启用断点续传,默认 False
filesize 字节 已知文件大小,传了就跳过 HEAD 探测

关于 farfarfun

farfarfun 是一个专注于实用工具库的开源组织, 涵盖云存储、数据处理、AI、多媒体与开发工具链等方向。

本项目基于 MIT 协议开源。

Metadata

Release files for funget 1.1.71

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for funget 1.1.71
File Size Uploaded
funget-1.1.71.tar.gz 76.0 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for funget 1.1.71
File
funget-1.1.71-cp312-abi3-win_amd64.whl CPython 3.12 abi3 Windows x86-64 Details
funget-1.1.71-cp312-abi3-musllinux_1_2_x86_64.whl CPython 3.12 abi3 Linux musl 1.2+ x86-64 Details
funget-1.1.71-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.12 abi3 Linux glibc 2.17+ x86-64 Details
funget-1.1.71-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.12 abi3 Linux glibc 2.17+ ARM64 Details
funget-1.1.71-cp312-abi3-macosx_11_0_arm64.whl CPython 3.12 abi3 macOS 11.0+ ARM64 Details
funget-1.1.71-cp312-abi3-macosx_10_12_x86_64.whl CPython 3.12 abi3 macOS 10.12+ x86-64 Details

Total release size: 12.5 MB

Release files / funget-1.1.71.tar.gz

Download URL funget-1.1.71.tar.gz
Size 76.0 kB
Tags Source
SHA-256 checksum
How to use checksums
233da7f8a445c745e833bbe048b5ebfbba47e37fe3411a750a616f3d0d351b6a
BLAKE2b-256 checksum
How to use checksums
e76ed41ec6cd44d9f18b77ae53381164ebf723fb8f7f0acc8355d6366c3f21f5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / funget-1.1.71-cp312-abi3-win_amd64.whl

Download URL funget-1.1.71-cp312-abi3-win_amd64.whl
Size 2.1 MB
Tags CPython 3.12 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
0826db60c37760b822d77b1a00f8f87303eb7c844458cf2eeed37606640c5c18
BLAKE2b-256 checksum
How to use checksums
1276f202d81eae69cf085a3faab0b3805f9691825cf284999f14818a6d8a20f6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / funget-1.1.71-cp312-abi3-musllinux_1_2_x86_64.whl

Download URL funget-1.1.71-cp312-abi3-musllinux_1_2_x86_64.whl
Size 2.3 MB
Tags CPython 3.12 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
cedca2a28843f95103eb45b0223e8472af5a7f0052a0d02a9fe7c06edd46ab9d
BLAKE2b-256 checksum
How to use checksums
f4b29aa98eb7396049c13b5262fcbf6f095900af22b98af2d987636236528b8d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / funget-1.1.71-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL funget-1.1.71-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 2.1 MB
Tags CPython 3.12 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
fa9a77d9fa95200064d7ab6cbafbbbb973bc3d1b782149e71083ee130d15fe98
BLAKE2b-256 checksum
How to use checksums
3a40e1a4a457d2035552bd36b1a9612f73dd67cf36f83cf460ab56c8f3f36578
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / funget-1.1.71-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL funget-1.1.71-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 2.0 MB
Tags CPython 3.12 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
c7d2447084b7cb6cb4a71f0c3f8a161c334e4f5fcaabc8b72a4d34da86bade45
BLAKE2b-256 checksum
How to use checksums
4b7ec965de8a440dd9d1c325852685f321c4bd6ef3959f67b188d8b6ff968905
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / funget-1.1.71-cp312-abi3-macosx_11_0_arm64.whl

Download URL funget-1.1.71-cp312-abi3-macosx_11_0_arm64.whl
Size 1.9 MB
Tags CPython 3.12 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
f68999b23655cba76579cb89d8b83c7d4d043e4c93410fd98a1390a37cc903f2
BLAKE2b-256 checksum
How to use checksums
fe8ba6f53d549e576abe312052a141e5be705f6ccce93d16ea0b38ca47220416
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / funget-1.1.71-cp312-abi3-macosx_10_12_x86_64.whl

Download URL funget-1.1.71-cp312-abi3-macosx_10_12_x86_64.whl
Size 2.0 MB
Tags CPython 3.12 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
46ccfaa096a7eeafb707c26bdea084f0fc7b9395b31bb078af9b77a62616002f
BLAKE2b-256 checksum
How to use checksums
2b1c545802f5dea5f6bc70baf2a8390c1d82d4ba074662dc18d9e72342dc8830
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

1.1.73

7 release files

1.1.72

7 release files

This release

1.1.71 This release

7 release files

1.1.69

1 release file

1.1.67

1 release file

1.1.63

1 release file

1.1.58

1 release file

1.1.57

1 release file

1.1.56

1 release file

1.1.55

1 release file

1.1.54

1 release file

1.1.53

1 release file

1.1.52

1 release file

1.1.51

1 release file

1.0.50

1 release file

1.0.48

2 release files

1.0.47

1 release file

1.0.46

1 release file

1.0.45

2 release files

1.0.44

2 release files

1.0.43

2 release files

1.0.41

2 release files

1.0.40

2 release files

1.0.38

2 release files

1.0.36

2 release files

1.0.35

2 release files

1.0.34

2 release files

1.0.33

2 release files

1.0.32

2 release files

1.0.31

2 release files

1.0.30

2 release files

1.0.29

2 release files

1.0.28

2 release files

1.0.27

2 release files

1.0.26

2 release files

1.0.25

2 release files

1.0.24

2 release files

1.0.23

2 release files

1.0.22

2 release files

1.0.21

2 release files

1.0.9

2 release files

1.0.8

2 release files

1.0.7

2 release files

1.0.6

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.1

2 release files

0.1.7

1 release file

0.1.6

1 release file

0.1.5

1 release file

0.1.4

1 release file

0.1.3

1 release file

0.1.2

1 release file

0.1.1

1 release file

0.1.0

1 release file

0.0.31

1 release file

0.0.30

1 release file

0.0.29

1 release file

0.0.28

1 release file

0.0.27

1 release file

0.0.26

1 release file

0.0.25

1 release file

0.0.24

1 release file

0.0.23

1 release file

0.0.22

1 release file

0.0.21

1 release file

0.0.20

1 release file

0.0.19

1 release file

0.0.18

1 release file

0.0.17

1 release file

0.0.16

1 release file

0.0.15

1 release file

0.0.14

1 release file

0.0.13

1 release file

0.0.12

1 release file

0.0.11

1 release file

0.0.10

1 release file

0.0.9

1 release file

0.0.8

1 release file

0.0.7

1 release file

0.0.6

1 release file

0.0.5

1 release file

0.0.4

1 release file

0.0.3

1 release file

0.0.2

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page