Skip to main content

Python Storage

Python 3.11 及以上;需要部署好的 Storage 控制面、项目 token,以及可达的 S3/MinIO 数据面。SDK 不安装或部署这些依赖。

安装

示例适用于 0.1.2,当前发布状态见发布矩阵。

python -m pip install stellarmesh-storage==0.1.2

最小完整示例

由业务构造 ClientConfig(base_url=服务地址, token=业务安全注入值),再调用下面函数。需要 documents 空间和对应 read/write 权限;同步例子写入 example.txt,异步例子下载它。测试用 HTTPX 替身验证控制面、数据面与关闭动作,业务中省略 transport 参数。

"""完整同步/异步示例;transport 参数用于本地验证,业务中可省略。"""

from pathlib import Path

import httpx

from stellarmesh_storage import (
    AsyncClient,
    Client,
    ClientConfig,
    ObjectInfo,
    StorageError,
)


def upload_example(
    config: ClientConfig,
    *,
    transport: httpx.BaseTransport | None = None,
    data_transport: httpx.BaseTransport | None = None,
) -> ObjectInfo:
    """需 documents 空间的 write/read 权限,写入 example.txt。"""
    try:
        with Client(
            config, transport=transport, data_transport=data_transport
        ) as client:
            client.upload_bytes("documents", "example.txt", b"example")
            return client.stat("documents", "example.txt")
    except StorageError as error:
        # 不记录 token、签名 URL 或底层响应;交给应用决定如何呈现错误。
        raise RuntimeError(f"对象上传失败:{type(error).__name__}") from error


async def download_example(
    config: ClientConfig,
    target: Path,
    *,
    transport: httpx.AsyncBaseTransport | None = None,
    data_transport: httpx.AsyncBaseTransport | None = None,
) -> Path:
    """需 read 权限和既有 example.txt;成功后会覆盖 target。"""
    try:
        async with AsyncClient(
            config, transport=transport, data_transport=data_transport
        ) as client:
            return await client.download_file("documents", "example.txt", target)
    except StorageError as error:
        raise RuntimeError(f"对象下载失败:{type(error).__name__}") from error

关键限制

客户端需用 with/async with 或显式 close/aclose 关闭。控制面 token 不发送给对象存储;签名 URL 与请求头必须保留。单次上传至多 5 GiB,分片生命周期由业务管理;下载成功会覆盖目标文件。

深入指南

接入与迁移、架构边界、贡献与验证。源码和注释以主干为准,已发布制品行为以对应 tag 为准。

Release files for stellarmesh-storage 0.1.2

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

Source distribution (sdist)

Source distribution for stellarmesh-storage 0.1.2
File Size Uploaded
stellarmesh_storage-0.1.2.tar.gz 18.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for stellarmesh-storage 0.1.2
File Interpreter ABI Platform
stellarmesh_storage-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 39.6 kB

Release files / stellarmesh_storage-0.1.2.tar.gz

Download URL stellarmesh_storage-0.1.2.tar.gz
Size 18.9 kB
Tags Source
SHA-256 checksum
How to use checksums
bcb833207db8c4f53c5809a53e536733d733b7ddb1307eead828690a2b5e0990
BLAKE2b-256 checksum
How to use checksums
7b40f76d8428ca9864014330cba99e42d7344a0d723683e0322f3f3c77b98a8b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 25, 2026.

Transparency log

Release files / stellarmesh_storage-0.1.2-py3-none-any.whl

Download URL stellarmesh_storage-0.1.2-py3-none-any.whl
Size 20.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b940ca072786fb0d928210d03f6f0308403756b88111b4a2d62c764a259a1c74
BLAKE2b-256 checksum
How to use checksums
2b2bf59eac6ccfc62022ca43f7637ef5fdac5836d64042efb253908c8c7bdb9e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 25, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

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