fiuai-s3 0.1.0__tar.gz → 0.1.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of fiuai-s3 might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fiuai-s3
3
- Version: 0.1.0
3
+ Version: 0.1.1
4
4
  Summary: 一个支持阿里云OSS和MinIO的对象存储抽象包
5
5
  Project-URL: Homepage, https://github.com/fiuai-sz/fiuai-s3
6
6
  Project-URL: Repository, https://github.com/fiuai-sz/fiuai-s3.git
@@ -247,48 +247,43 @@ pip install fiuai-s3
247
247
  ### 初始化存储
248
248
 
249
249
  ```python
250
+ # file: utils/s3.py
250
251
  from fiuai_s3 import ObjectStorageFactory
252
+ from config.app_config import get_settings
251
253
 
252
- # 初始化MinIO存储
253
254
  ObjectStorageFactory.initialize(
254
- provider="minio",
255
- bucket_name="dev",
256
- endpoint="http://127.0.0.1:19000",
257
- access_key="devdevdev",
258
- secret_key="devdevdev",
259
- temp_dir="temp/",
260
- use_https=False
255
+ # 初始化对象存储
256
+ provider=get_settings().object_storage_config.provider,
257
+ bucket_name=get_settings().object_storage_config.bucket_name,
258
+ endpoint=get_settings().object_storage_config.endpoint,
259
+ access_key=get_settings().object_storage_config.access_key,
260
+ secret_key=get_settings().object_storage_config.secret_key,
261
+ temp_dir=get_settings().object_storage_config.s3_temp_dir,
262
+ use_https=get_settings().object_storage_config.s3_use_https
263
+
261
264
  )
265
+ S3_Client = ObjectStorageFactory.get_instance()
262
266
 
263
- # 或者初始化阿里云OSS存储
264
- ObjectStorageFactory.initialize(
265
- provider="alicloud",
266
- bucket_name="your-bucket",
267
- endpoint="oss-cn-hangzhou.aliyuncs.com",
268
- access_key="your-access-key",
269
- secret_key="your-secret-key",
270
- temp_dir="temp/",
271
- use_https=True
272
- )
273
267
  ```
274
268
 
269
+
275
270
  ### 使用存储实例
276
271
 
277
272
  ```python
278
- # 获取存储实例
279
- storage = ObjectStorageFactory.get_instance()
273
+ # file: app.py
274
+ from utils.s3 import S3_Client
280
275
 
281
276
  # 上传文件
282
- storage.upload_file("test.txt", b"Hello World")
277
+ S3_Client.upload_file("test.txt", b"Hello World")
283
278
 
284
279
  # 下载文件
285
- data = storage.download_file("test.txt")
280
+ data = S3_Client.download_file("test.txt")
286
281
 
287
282
  # 删除文件
288
- storage.delete_file("test.txt")
283
+ S3_Client.delete_file("test.txt")
289
284
 
290
285
  # 列出文件
291
- files = storage.list_files(prefix="test/")
286
+ files = S3_Client.list_files(prefix="test/")
292
287
  ```
293
288
 
294
289
  ## 配置参数
@@ -308,7 +303,7 @@ files = storage.list_files(prefix="test/")
308
303
  ### 安装开发依赖
309
304
 
310
305
  ```bash
311
- pip install -r requirements.txt
306
+ uv pip install .
312
307
  ```
313
308
 
314
309
  ### 运行测试
@@ -22,48 +22,43 @@ pip install fiuai-s3
22
22
  ### 初始化存储
23
23
 
24
24
  ```python
25
+ # file: utils/s3.py
25
26
  from fiuai_s3 import ObjectStorageFactory
27
+ from config.app_config import get_settings
26
28
 
27
- # 初始化MinIO存储
28
29
  ObjectStorageFactory.initialize(
29
- provider="minio",
30
- bucket_name="dev",
31
- endpoint="http://127.0.0.1:19000",
32
- access_key="devdevdev",
33
- secret_key="devdevdev",
34
- temp_dir="temp/",
35
- use_https=False
30
+ # 初始化对象存储
31
+ provider=get_settings().object_storage_config.provider,
32
+ bucket_name=get_settings().object_storage_config.bucket_name,
33
+ endpoint=get_settings().object_storage_config.endpoint,
34
+ access_key=get_settings().object_storage_config.access_key,
35
+ secret_key=get_settings().object_storage_config.secret_key,
36
+ temp_dir=get_settings().object_storage_config.s3_temp_dir,
37
+ use_https=get_settings().object_storage_config.s3_use_https
38
+
36
39
  )
40
+ S3_Client = ObjectStorageFactory.get_instance()
37
41
 
38
- # 或者初始化阿里云OSS存储
39
- ObjectStorageFactory.initialize(
40
- provider="alicloud",
41
- bucket_name="your-bucket",
42
- endpoint="oss-cn-hangzhou.aliyuncs.com",
43
- access_key="your-access-key",
44
- secret_key="your-secret-key",
45
- temp_dir="temp/",
46
- use_https=True
47
- )
48
42
  ```
49
43
 
44
+
50
45
  ### 使用存储实例
51
46
 
52
47
  ```python
53
- # 获取存储实例
54
- storage = ObjectStorageFactory.get_instance()
48
+ # file: app.py
49
+ from utils.s3 import S3_Client
55
50
 
56
51
  # 上传文件
57
- storage.upload_file("test.txt", b"Hello World")
52
+ S3_Client.upload_file("test.txt", b"Hello World")
58
53
 
59
54
  # 下载文件
60
- data = storage.download_file("test.txt")
55
+ data = S3_Client.download_file("test.txt")
61
56
 
62
57
  # 删除文件
63
- storage.delete_file("test.txt")
58
+ S3_Client.delete_file("test.txt")
64
59
 
65
60
  # 列出文件
66
- files = storage.list_files(prefix="test/")
61
+ files = S3_Client.list_files(prefix="test/")
67
62
  ```
68
63
 
69
64
  ## 配置参数
@@ -83,7 +78,7 @@ files = storage.list_files(prefix="test/")
83
78
  ### 安装开发依赖
84
79
 
85
80
  ```bash
86
- pip install -r requirements.txt
81
+ uv pip install .
87
82
  ```
88
83
 
89
84
  ### 运行测试
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "fiuai-s3"
7
- version = "0.1.0"
7
+ version = "0.1.1"
8
8
  description = "一个支持阿里云OSS和MinIO的对象存储抽象包"
9
9
  readme = "README.md"
10
10
  authors = [
@@ -175,7 +175,6 @@ class ObjectStorageFactory:
175
175
  # 导出工厂类
176
176
  __all__ = ['ObjectStorage', 'ObjectStorageFactory', 'StorageConfig']
177
177
 
178
- # 创建全局对象存储实例
179
- Storage = ObjectStorageFactory.get_instance()
178
+
180
179
 
181
180
 
File without changes
File without changes