一个支持阿里云OSS和MinIO的对象存储抽象包
Project description
FiuAI S3
一个支持阿里云OSS和MinIO的对象存储抽象包,提供了统一的接口来操作不同的对象存储服务。
特性
- 支持阿里云OSS和MinIO存储服务
- 统一的接口设计
- 工厂模式实现,易于扩展
- 完整的类型提示
- 详细的日志记录
- 异常处理机制
安装
pip install fiuai-s3
快速开始
初始化存储
from fiuai_s3 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
fiuai_s3-0.1.0.tar.gz
(11.3 kB
view details)
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
fiuai_s3-0.1.0-py3-none-any.whl
(15.9 kB
view details)
File details
Details for the file fiuai_s3-0.1.0.tar.gz.
File metadata
- Download URL: fiuai_s3-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 |
fa007d7e9993500fb05c8a815b10e7ee2b9627dda77df57ab3c43ce9431931e8
|
|
| MD5 |
85e8dcd6e8b92e62502c3d81998dcd47
|
|
| BLAKE2b-256 |
ee62c93aa6e5fb865520cf479dcd90d15e46c9ec720e4145188dc8d7f5a4b8e8
|
File details
Details for the file fiuai_s3-0.1.0-py3-none-any.whl.
File metadata
- Download URL: fiuai_s3-0.1.0-py3-none-any.whl
- Upload date:
- Size: 15.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.28.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
32a3e14644270e26c35ff0310d8250ed3719e0b384162ad0d9d0967b97d6383d
|
|
| MD5 |
60111c1f10341a7036f1de5fc798abe3
|
|
| BLAKE2b-256 |
86f2c19394403f0207a95c36d14dd0bc8240700d09facd74f0e2c500b1001d07
|