Skip to main content

图床上传工具

Project description

介绍

在上传图片的时候, 经常会用到图床功能.

此工具聚合了一些常用的图床, 以便于快速使用.

注意: 因免费图床的稳定性无法保证, 因此请勿用其保存重要文件

说明

因为使用各种免费服务, 稳定性无法保证

若各位在使用过程中碰到问题, 欢迎下列任选一种方式补充:

  1. 提交isuse说明问题
  2. 将问题写到DepotType的对应文档上

如果你有其他优秀的图床推荐, 欢迎提交isusePR

当前支持的所有图床, 可查看文件DepotType

使用

安装:

pip install image-depot

指定单个图床进行上传

from image_depot import image_depot, DepotType

# 选择图床对象
d = image_depot(DepotType.CatBox)
if d is None:  # 当前图床已失效
    pass

# 上传图片. 二进制内容
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


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.10.0.tar.gz (12.9 kB view details)

Uploaded Source

Built Distribution

image_depot-0.10.0-py3-none-any.whl (23.8 kB view details)

Uploaded Python 3

File details

Details for the file image_depot-0.10.0.tar.gz.

File metadata

  • Download URL: image_depot-0.10.0.tar.gz
  • Upload date:
  • Size: 12.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.1

File hashes

Hashes for image_depot-0.10.0.tar.gz
Algorithm Hash digest
SHA256 b540a5494c3c6b42657a46ceee5ee489e2f6f4e599175e4e71781711863fc7c7
MD5 4057a1a90e25eb4182967577411698ec
BLAKE2b-256 044f3cb9e3c5f915d092728f54affcee33d4e05bc5f97395e8d7c385e6ecc0ee

See more details on using hashes here.

File details

Details for the file image_depot-0.10.0-py3-none-any.whl.

File metadata

  • Download URL: image_depot-0.10.0-py3-none-any.whl
  • Upload date:
  • Size: 23.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.1

File hashes

Hashes for image_depot-0.10.0-py3-none-any.whl
Algorithm Hash digest
SHA256 06bb6d9ef291ab7e17a689912981d8422a66a27c0faf7a8a2a4fe1f424bdac98
MD5 cc358525e92c358f5e7b04b86a4b7280
BLAKE2b-256 2f462abb3245d2c92787756a015452c7a1416b2f71a56e7bfee0e9056bd4cc77

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page