up2s3
这是基于 sapic 图床(v2)的一个扩展模块, 用来将上传的图片保存到 AWS S3(或任意 S3 兼容服务)。
钩子名(模块名):up2s3
扩展类型:upload(存储驱动)
适用版本:sapic 2.x(V1 的 g.cfg / intpl_localhooksetting 契约已废弃)
安装
正式版本
$ pip install -U up2s3
开发版本
$ pip install -U git+https://github.com/sapicd/up2s3.git@master
依赖 boto3;未安装时钩子仍能加载,只是上传会返回 Please install boto3 module。
开始使用
添加:
在 站点管理-钩子插件 中导入模块名 up2s3(或 POST /api/v2/hooks/import), 然后启用它。启用后 sapic 会自动创建一条同名存储后端。
配置:
在 站点管理-存储后端 里为该后端填写(不是旧的“网站设置”):
bucket(必填):S3 存储桶名称
access_key_id(必填):AWS 访问密钥 ID,可用有 S3 权限的 IAM 子用户
secret_key(必填):AWS 访问密钥密码
region:地域,如 ap-northeast-1;留空则自动探测(需 s3:GetBucketLocation)
endpoint:S3 兼容服务的 Endpoint,如 https://minio.example.com;AWS 留空
domain:自定义域名/CloudFront 域名;留空则由 sapic 的 /raw/<sha> 代理输出
acl:上传时写入的对象 ACL(不设置 / public-read / private), 默认不设置,由桶策略决定。AWS 新版桶默认禁用 ACL,选 public-read 会报 AccessControlListNotSupported
basedir:存储根目录,默认桶根目录
thumb_suffix:缩略图参数,如 ?width=400
填好后可点「检查存储桶」验证凭证与桶是否可达。
直链规则:配了 domain 就用它;没配但 acl 是 public-read 且未使用自定义 endpoint 时,回退到 https://<bucket>.s3.<region>.amazonaws.com/<key>;其余 情况由 /raw/<sha> 输出。V1 会强制写入 public-read,V2 改成按配置决定。
同一个驱动可以建多条存储后端(不同桶、不同密钥、不同优先级),上传走优先级 最高的那条,其余作为异步副本;判断依据是后端行的 priority(数值越小越优先)。
私有桶(签名读):
桶为私有读时,把后端的「访问方式」设为 private 即可,domain 可留空:
本驱动实现了 upimg_url,后台不会再报 driver cannot read private objects;
图片直链固定为 /raw/<sha>,sapic 请求本驱动签发 generate_presigned_url 的 临时地址(有效期由核心决定,默认 300 秒),在服务端拉取并流式转发,签名与凭证 都不会出现在浏览器;
签名针对 S3 源站(或自定义 endpoint),不针对 CloudFront/自定义域名;
private 后端不再返回 src,需要 CDN 直链的可同时建一个 public 后端副本。
V1 升级提示
V2 的配置存在存储后端行里,V1 站点设置中的 s3_* 不会自动迁移,需要重新填写 一次;已上传图片的记录与旧直链不受影响。
Metadata
Release files for up2s3 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 |
|---|---|---|---|---|
| up2s3-0.2.0.tar.gz | 11.9 kB | Without provenance | Details for up2s3-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| up2s3-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for up2s3-0.2.0-py3-none-any.whl |
Total release size: 23.9 kB
Release files / up2s3-0.2.0.tar.gz
| Download URL | up2s3-0.2.0.tar.gz |
|---|---|
| Size | 11.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1f52693b5def48c5044490c9dc7bd81ff467db354ff707cae0ebff0bc33ad10f
|
|
BLAKE2b-256 checksum How to use checksums |
10f36a745c3a35c69aca7a03699cd5afc59ea891c42b37ce5f54103df4fa30c3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.9
|
Release files / up2s3-0.2.0-py3-none-any.whl
| Download URL | up2s3-0.2.0-py3-none-any.whl |
|---|---|
| Size | 12.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
be0698d7c63189478d8cc045116148c697b3499fb0020b4b7d2a9ac3b612dd9a
|
|
BLAKE2b-256 checksum How to use checksums |
a1a25f715d148371db1f62a6d9c3e9a0f3be43bace366fdfcf68a081c897b365
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.9
|
Security for up2s3 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.