up2b2
这是基于 sapic 图床(v2)的一个扩展模块, 用来将上传的图片保存到 Backblaze B2。
钩子名(模块名):up2b2
扩展类型:upload(存储驱动)
适用版本:sapic 2.x(V1 的 g.cfg / intpl_localhooksetting 契约已废弃)
安装
正式版本
$ pip install -U up2b2
开发版本
$ pip install -U git+https://github.com/sapicd/up2b2.git@master
依赖 b2sdk;未安装时钩子仍能加载,只是上传会返回 Please install b2sdk module。
开始使用
添加:
在 站点管理-钩子插件 中导入模块名 up2b2(或 POST /api/v2/hooks/import), 然后启用它。启用后 sapic 会自动创建一条同名存储后端。
配置:
在 站点管理-存储后端 里为该后端填写(不是旧的“网站设置”):
bucket(必填):B2 存储桶名称
key_id(必填):应用密钥的 keyID(账户-应用密钥)
application_key(必填):应用密钥 applicationKey,需读写删除权限
domain:下载前缀;留空则由 sapic 的 /raw/<sha> 输出。任选一种:
友好 URL:https://f005.backblazeb2.com/file/<Bucket>
S3 URL:https://<Bucket>.s3.us-east-005.backblazeb2.com
basedir:存储根目录,默认桶根目录
thumb_suffix:缩略图参数,如 ?width=400(CDN 图片处理)
填好后可点「检查存储桶」验证凭证与桶是否可达。
etag 约定:B2 没有 S3 那种 ETag,本驱动把**文件版本 id** 写进 etag, 删除与签名读都据此精确定位版本;早期没有版本 id 的记录会按文件名查一次。
同一个驱动可以建多条存储后端(不同桶、不同密钥、不同优先级),上传走优先级 最高的那条,其余作为异步副本;判断依据是后端行的 priority(数值越小越优先)。
私有桶(签名读):
桶为私有读时,把后端的「访问方式」设为 private 即可,domain 可留空:
本驱动实现了 upimg_url,后台不会再报 driver cannot read private objects;
图片直链固定为 /raw/<sha>,sapic 向本驱动要临时下载地址并在服务端拉取转发: 优先用文件版本 id 换取带令牌的下载地址,没有版本 id 时用 get_download_authorization 签发(该方式要求密钥具备 shareFiles 能力);
private 后端不再返回 src,需要 CDN 直链的可同时建一个 public 后端副本。
V1 升级提示
V2 的配置存在存储后端行里,V1 站点设置中的 b2_* 不会自动迁移,需要重新填写 一次;已上传图片的记录与旧直链不受影响。
Metadata
Release files for up2b2 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| up2b2-0.2.0.tar.gz | 11.3 kB | Without provenance | Details for up2b2-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| up2b2-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for up2b2-0.2.0-py3-none-any.whl |
Total release size: 22.6 kB
Release files / up2b2-0.2.0.tar.gz
| Download URL | up2b2-0.2.0.tar.gz |
|---|---|
| Size | 11.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
967de4713f765ef829ba7a820021f986e0d4514ab43bf4ea46a24e11059d8e99
|
|
BLAKE2b-256 checksum How to use checksums |
ae80e8f572ab9745a0d4925652d1c84b687aab9630727ea61bbbdbb4c4f28b57
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.9
|
Release files / up2b2-0.2.0-py3-none-any.whl
| Download URL | up2b2-0.2.0-py3-none-any.whl |
|---|---|
| Size | 11.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a106f6ee076c7ff459d390b7bad44befef0824ca0067a1ec5ce1bb119f25f524
|
|
BLAKE2b-256 checksum How to use checksums |
a716c8080c0b0e2f0bbdb3b0fe3d093ddaa682bb92481e3f4c1f6426257e5ea2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.9
|
Security for up2b2 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.