图床上传工具
Project description
介绍
在上传图片的时候, 经常会用到图床功能.
此工具聚合了一些常用的图床, 以便于快速使用. 演示站点
注意: 因免费图床的稳定性无法保证, 因此请勿用其保存重要文件
说明
因为使用各种免费服务, 稳定性无法保证
若各位在使用过程中碰到问题, 欢迎下列任选一种方式补充:
- 提交
isuse
说明问题 - 将问题写到
DepotType
的对应文档上
如果你有其他优秀的图床推荐, 欢迎提交isuse
或PR
当前支持的所有图床, 可查看文件DepotType
使用
安装:
pip install image-depot
指定单个图床进行上传
from image_depot import image_depot, DepotType
# 选择图床对象
d = image_depot(DepotType.CatBox)
# 上传图片. 二进制内容
image_content = ''
image_url = d.upload(image_content)
if not image_url: # 图片上传失败, 获取失败原因
print(d.error())
# 上传图片, 使用本地文件路径
file_path = ''
image_url = d.upload_file(file_path)
多个图床依次尝试上传:
from image_depot import upload, upload_file, DepotType
type_list = [DepotType.SmMs]
# 上传图片. 二进制内容. 若所有图床都上传失败, 则返回空字符串以及所有错误信息
image_content = ''
url, err = upload(image_content, type_list=type_list)
# 依次尝试所有图床, 返回第一个成功的.
file_path = ''
upload_file(file_path, type_list=type_list)
图床配置:
from image_depot import image_depot, DepotType, upload, upload_file, DepotConfig, set_global_config
# 部分图床需要添加配置才能使用
# 全局配置
config = DepotConfig()
config.sm_ms.token = ''
set_global_config(config)
# 可以为每次上传使用不同的配置信息
# 此配置优先级高于 global_config
d = image_depot(DepotType.CatBox)
d.set_config(config)
upload('', config=config)
upload_file('', config=config)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
image_depot-0.12.1.tar.gz
(13.9 kB
view details)
Built Distribution
File details
Details for the file image_depot-0.12.1.tar.gz
.
File metadata
- Download URL: image_depot-0.12.1.tar.gz
- Upload date:
- Size: 13.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5f63db3704984bf85790ba4103f9685ed540c4ac962fd402cd119efdf9dfb9dd |
|
MD5 | d9e878da656dcfc1ad828753077de766 |
|
BLAKE2b-256 | 5442603df89b67861a7d675c90c269f28a593af33fa7d6d0d9f51769408ceb14 |
File details
Details for the file image_depot-0.12.1-py3-none-any.whl
.
File metadata
- Download URL: image_depot-0.12.1-py3-none-any.whl
- Upload date:
- Size: 25.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6ab0ce72fec29829fd79f20dcd08f287c173d6f4f3a8d31d360338c42c75d183 |
|
MD5 | 906913d2b380c5eb0aff2c8bde041185 |
|
BLAKE2b-256 | e96313e6ca96f989c9a52bd738e973e7ac66b65f7eae7335fde2b4bef9609b56 |