一个支持阿里云OSS和MinIO的对象存储抽象包
This project has been archived.
The maintainers of this project have marked this project as archived. No new releases are expected.
Project description
FiuAI Object Storage
一个支持阿里云OSS和MinIO的对象存储抽象包,提供了统一的接口来操作不同的对象存储服务。
特性
- 支持阿里云OSS和MinIO存储服务
- 统一的接口设计
- 工厂模式实现,易于扩展
- 完整的类型提示
- 详细的日志记录
- 异常处理机制
安装
pip install fiuai-object-storage
快速开始
初始化存储
from object_storage import ObjectStorageFactory
# 初始化MinIO存储
ObjectStorageFactory.initialize(
provider="minio",
bucket_name="dev",
endpoint="http://127.0.0.1:19000",
access_key="devdevdev",
secret_key="devdevdev",
temp_dir="temp/",
use_https=False
)
# 或者初始化阿里云OSS存储
ObjectStorageFactory.initialize(
provider="alicloud",
bucket_name="your-bucket",
endpoint="oss-cn-hangzhou.aliyuncs.com",
access_key="your-access-key",
secret_key="your-secret-key",
temp_dir="temp/",
use_https=True
)
使用存储实例
# 获取存储实例
storage = ObjectStorageFactory.get_instance()
# 上传文件
storage.upload_file("test.txt", b"Hello World")
# 下载文件
data = storage.download_file("test.txt")
# 删除文件
storage.delete_file("test.txt")
# 列出文件
files = storage.list_files(prefix="test/")
配置参数
| 参数 | 类型 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|
| provider | str | 是 | - | 存储提供商,支持 "alicloud" 或 "minio" |
| bucket_name | str | 是 | - | 存储桶名称 |
| endpoint | str | 是 | - | 存储服务端点 |
| access_key | str | 是 | - | 访问密钥 |
| secret_key | str | 是 | - | 密钥 |
| temp_dir | str | 否 | "temp/" | 临时目录 |
| use_https | bool | 否 | False | 是否使用HTTPS |
开发
安装开发依赖
pip install -r requirements.txt
运行测试
python -m pytest tests/
许可证
MIT License
作者
- liming (lmlala@aliyun.com)
贡献
欢迎提交 Issue 和 Pull Request!
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fiuai_object_storage-0.1.0.tar.gz.
File metadata
- Download URL: fiuai_object_storage-0.1.0.tar.gz
- Upload date:
- Size: 11.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.28.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0804fa009f1a2530dc6341f54a87fe5592f03b798431132144c14b1e5d9b555a
|
|
| MD5 |
5e1d7a7d70759f0b93c5e5f4f4dbc924
|
|
| BLAKE2b-256 |
a32bff070bd83fc4dc46448a96950e372884190d01269bec579e29240afae27a
|
File details
Details for the file fiuai_object_storage-0.1.0-py3-none-any.whl.
File metadata
- Download URL: fiuai_object_storage-0.1.0-py3-none-any.whl
- Upload date:
- Size: 16.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.28.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8de1ccf3a39f9d136d3e6fcfd6a1ae7100bc0766c005b9602b4f518d1c7e68af
|
|
| MD5 |
13f137018b1d7324d4ffa4a8f265d8e5
|
|
| BLAKE2b-256 |
bc31c15127ca23e67494a293afdfe5bdb6f3f1ab6aef585ccd58aa8d11ab8bfe
|