fiuai-s3 0.1.0__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.

@@ -0,0 +1,174 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py,cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ #Pipfile.lock
96
+
97
+ # UV
98
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ #uv.lock
102
+
103
+ # poetry
104
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
106
+ # commonly ignored for libraries.
107
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108
+ #poetry.lock
109
+
110
+ # pdm
111
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
112
+ #pdm.lock
113
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
114
+ # in version control.
115
+ # https://pdm.fming.dev/latest/usage/project/#working-with-version-control
116
+ .pdm.toml
117
+ .pdm-python
118
+ .pdm-build/
119
+
120
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
121
+ __pypackages__/
122
+
123
+ # Celery stuff
124
+ celerybeat-schedule
125
+ celerybeat.pid
126
+
127
+ # SageMath parsed files
128
+ *.sage.py
129
+
130
+ # Environments
131
+ .env
132
+ .venv
133
+ env/
134
+ venv/
135
+ ENV/
136
+ env.bak/
137
+ venv.bak/
138
+
139
+ # Spyder project settings
140
+ .spyderproject
141
+ .spyproject
142
+
143
+ # Rope project settings
144
+ .ropeproject
145
+
146
+ # mkdocs documentation
147
+ /site
148
+
149
+ # mypy
150
+ .mypy_cache/
151
+ .dmypy.json
152
+ dmypy.json
153
+
154
+ # Pyre type checker
155
+ .pyre/
156
+
157
+ # pytype static type analyzer
158
+ .pytype/
159
+
160
+ # Cython debug symbols
161
+ cython_debug/
162
+
163
+ # PyCharm
164
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
165
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
166
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
167
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
168
+ #.idea/
169
+
170
+ # Ruff stuff:
171
+ .ruff_cache/
172
+
173
+ # PyPI configuration file
174
+ .pypirc
fiuai_s3-0.1.0/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,330 @@
1
+ Metadata-Version: 2.4
2
+ Name: fiuai-s3
3
+ Version: 0.1.0
4
+ Summary: 一个支持阿里云OSS和MinIO的对象存储抽象包
5
+ Project-URL: Homepage, https://github.com/fiuai-sz/fiuai-s3
6
+ Project-URL: Repository, https://github.com/fiuai-sz/fiuai-s3.git
7
+ Author-email: liming <lmlala@aliyun.com>
8
+ License: Apache License
9
+ Version 2.0, January 2004
10
+ http://www.apache.org/licenses/
11
+
12
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
13
+
14
+ 1. Definitions.
15
+
16
+ "License" shall mean the terms and conditions for use, reproduction,
17
+ and distribution as defined by Sections 1 through 9 of this document.
18
+
19
+ "Licensor" shall mean the copyright owner or entity authorized by
20
+ the copyright owner that is granting the License.
21
+
22
+ "Legal Entity" shall mean the union of the acting entity and all
23
+ other entities that control, are controlled by, or are under common
24
+ control with that entity. For the purposes of this definition,
25
+ "control" means (i) the power, direct or indirect, to cause the
26
+ direction or management of such entity, whether by contract or
27
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
28
+ outstanding shares, or (iii) beneficial ownership of such entity.
29
+
30
+ "You" (or "Your") shall mean an individual or Legal Entity
31
+ exercising permissions granted by this License.
32
+
33
+ "Source" form shall mean the preferred form for making modifications,
34
+ including but not limited to software source code, documentation
35
+ source, and configuration files.
36
+
37
+ "Object" form shall mean any form resulting from mechanical
38
+ transformation or translation of a Source form, including but
39
+ not limited to compiled object code, generated documentation,
40
+ and conversions to other media types.
41
+
42
+ "Work" shall mean the work of authorship, whether in Source or
43
+ Object form, made available under the License, as indicated by a
44
+ copyright notice that is included in or attached to the work
45
+ (an example is provided in the Appendix below).
46
+
47
+ "Derivative Works" shall mean any work, whether in Source or Object
48
+ form, that is based on (or derived from) the Work and for which the
49
+ editorial revisions, annotations, elaborations, or other modifications
50
+ represent, as a whole, an original work of authorship. For the purposes
51
+ of this License, Derivative Works shall not include works that remain
52
+ separable from, or merely link (or bind by name) to the interfaces of,
53
+ the Work and Derivative Works thereof.
54
+
55
+ "Contribution" shall mean any work of authorship, including
56
+ the original version of the Work and any modifications or additions
57
+ to that Work or Derivative Works thereof, that is intentionally
58
+ submitted to Licensor for inclusion in the Work by the copyright owner
59
+ or by an individual or Legal Entity authorized to submit on behalf of
60
+ the copyright owner. For the purposes of this definition, "submitted"
61
+ means any form of electronic, verbal, or written communication sent
62
+ to the Licensor or its representatives, including but not limited to
63
+ communication on electronic mailing lists, source code control systems,
64
+ and issue tracking systems that are managed by, or on behalf of, the
65
+ Licensor for the purpose of discussing and improving the Work, but
66
+ excluding communication that is conspicuously marked or otherwise
67
+ designated in writing by the copyright owner as "Not a Contribution."
68
+
69
+ "Contributor" shall mean Licensor and any individual or Legal Entity
70
+ on behalf of whom a Contribution has been received by Licensor and
71
+ subsequently incorporated within the Work.
72
+
73
+ 2. Grant of Copyright License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ copyright license to reproduce, prepare Derivative Works of,
77
+ publicly display, publicly perform, sublicense, and distribute the
78
+ Work and such Derivative Works in Source or Object form.
79
+
80
+ 3. Grant of Patent License. Subject to the terms and conditions of
81
+ this License, each Contributor hereby grants to You a perpetual,
82
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
83
+ (except as stated in this section) patent license to make, have made,
84
+ use, offer to sell, sell, import, and otherwise transfer the Work,
85
+ where such license applies only to those patent claims licensable
86
+ by such Contributor that are necessarily infringed by their
87
+ Contribution(s) alone or by combination of their Contribution(s)
88
+ with the Work to which such Contribution(s) was submitted. If You
89
+ institute patent litigation against any entity (including a
90
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
91
+ or a Contribution incorporated within the Work constitutes direct
92
+ or contributory patent infringement, then any patent licenses
93
+ granted to You under this License for that Work shall terminate
94
+ as of the date such litigation is filed.
95
+
96
+ 4. Redistribution. You may reproduce and distribute copies of the
97
+ Work or Derivative Works thereof in any medium, with or without
98
+ modifications, and in Source or Object form, provided that You
99
+ meet the following conditions:
100
+
101
+ (a) You must give any other recipients of the Work or
102
+ Derivative Works a copy of this License; and
103
+
104
+ (b) You must cause any modified files to carry prominent notices
105
+ stating that You changed the files; and
106
+
107
+ (c) You must retain, in the Source form of any Derivative Works
108
+ that You distribute, all copyright, patent, trademark, and
109
+ attribution notices from the Source form of the Work,
110
+ excluding those notices that do not pertain to any part of
111
+ the Derivative Works; and
112
+
113
+ (d) If the Work includes a "NOTICE" text file as part of its
114
+ distribution, then any Derivative Works that You distribute must
115
+ include a readable copy of the attribution notices contained
116
+ within such NOTICE file, excluding those notices that do not
117
+ pertain to any part of the Derivative Works, in at least one
118
+ of the following places: within a NOTICE text file distributed
119
+ as part of the Derivative Works; within the Source form or
120
+ documentation, if provided along with the Derivative Works; or,
121
+ within a display generated by the Derivative Works, if and
122
+ wherever such third-party notices normally appear. The contents
123
+ of the NOTICE file are for informational purposes only and
124
+ do not modify the License. You may add Your own attribution
125
+ notices within Derivative Works that You distribute, alongside
126
+ or as an addendum to the NOTICE text from the Work, provided
127
+ that such additional attribution notices cannot be construed
128
+ as modifying the License.
129
+
130
+ You may add Your own copyright statement to Your modifications and
131
+ may provide additional or different license terms and conditions
132
+ for use, reproduction, or distribution of Your modifications, or
133
+ for any such Derivative Works as a whole, provided Your use,
134
+ reproduction, and distribution of the Work otherwise complies with
135
+ the conditions stated in this License.
136
+
137
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
138
+ any Contribution intentionally submitted for inclusion in the Work
139
+ by You to the Licensor shall be under the terms and conditions of
140
+ this License, without any additional terms or conditions.
141
+ Notwithstanding the above, nothing herein shall supersede or modify
142
+ the terms of any separate license agreement you may have executed
143
+ with Licensor regarding such Contributions.
144
+
145
+ 6. Trademarks. This License does not grant permission to use the trade
146
+ names, trademarks, service marks, or product names of the Licensor,
147
+ except as required for reasonable and customary use in describing the
148
+ origin of the Work and reproducing the content of the NOTICE file.
149
+
150
+ 7. Disclaimer of Warranty. Unless required by applicable law or
151
+ agreed to in writing, Licensor provides the Work (and each
152
+ Contributor provides its Contributions) on an "AS IS" BASIS,
153
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
154
+ implied, including, without limitation, any warranties or conditions
155
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
156
+ PARTICULAR PURPOSE. You are solely responsible for determining the
157
+ appropriateness of using or redistributing the Work and assume any
158
+ risks associated with Your exercise of permissions under this License.
159
+
160
+ 8. Limitation of Liability. In no event and under no legal theory,
161
+ whether in tort (including negligence), contract, or otherwise,
162
+ unless required by applicable law (such as deliberate and grossly
163
+ negligent acts) or agreed to in writing, shall any Contributor be
164
+ liable to You for damages, including any direct, indirect, special,
165
+ incidental, or consequential damages of any character arising as a
166
+ result of this License or out of the use or inability to use the
167
+ Work (including but not limited to damages for loss of goodwill,
168
+ work stoppage, computer failure or malfunction, or any and all
169
+ other commercial damages or losses), even if such Contributor
170
+ has been advised of the possibility of such damages.
171
+
172
+ 9. Accepting Warranty or Additional Liability. While redistributing
173
+ the Work or Derivative Works thereof, You may choose to offer,
174
+ and charge a fee for, acceptance of support, warranty, indemnity,
175
+ or other liability obligations and/or rights consistent with this
176
+ License. However, in accepting such obligations, You may act only
177
+ on Your own behalf and on Your sole responsibility, not on behalf
178
+ of any other Contributor, and only if You agree to indemnify,
179
+ defend, and hold each Contributor harmless for any liability
180
+ incurred by, or claims asserted against, such Contributor by reason
181
+ of your accepting any such warranty or additional liability.
182
+
183
+ END OF TERMS AND CONDITIONS
184
+
185
+ APPENDIX: How to apply the Apache License to your work.
186
+
187
+ To apply the Apache License to your work, attach the following
188
+ boilerplate notice, with the fields enclosed by brackets "[]"
189
+ replaced with your own identifying information. (Don't include
190
+ the brackets!) The text should be enclosed in the appropriate
191
+ comment syntax for the file format. We also recommend that a
192
+ file or class name and description of purpose be included on the
193
+ same "printed page" as the copyright notice for easier
194
+ identification within third-party archives.
195
+
196
+ Copyright [yyyy] [name of copyright owner]
197
+
198
+ Licensed under the Apache License, Version 2.0 (the "License");
199
+ you may not use this file except in compliance with the License.
200
+ You may obtain a copy of the License at
201
+
202
+ http://www.apache.org/licenses/LICENSE-2.0
203
+
204
+ Unless required by applicable law or agreed to in writing, software
205
+ distributed under the License is distributed on an "AS IS" BASIS,
206
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
207
+ See the License for the specific language governing permissions and
208
+ limitations under the License.
209
+ License-File: LICENSE
210
+ Classifier: Development Status :: 3 - Alpha
211
+ Classifier: Intended Audience :: Developers
212
+ Classifier: License :: OSI Approved :: MIT License
213
+ Classifier: Operating System :: OS Independent
214
+ Classifier: Programming Language :: Python :: 3
215
+ Classifier: Programming Language :: Python :: 3.7
216
+ Classifier: Programming Language :: Python :: 3.8
217
+ Classifier: Programming Language :: Python :: 3.9
218
+ Classifier: Programming Language :: Python :: 3.10
219
+ Requires-Python: >=3.7
220
+ Requires-Dist: hatch>=1.7.0
221
+ Requires-Dist: minio>=7.1.0
222
+ Requires-Dist: oss2>=2.15.0
223
+ Requires-Dist: pydantic>=1.8.0
224
+ Description-Content-Type: text/markdown
225
+
226
+ # FiuAI S3
227
+
228
+ 一个支持阿里云OSS和MinIO的对象存储抽象包,提供了统一的接口来操作不同的对象存储服务。
229
+
230
+ ## 特性
231
+
232
+ - 支持阿里云OSS和MinIO存储服务
233
+ - 统一的接口设计
234
+ - 工厂模式实现,易于扩展
235
+ - 完整的类型提示
236
+ - 详细的日志记录
237
+ - 异常处理机制
238
+
239
+ ## 安装
240
+
241
+ ```bash
242
+ pip install fiuai-s3
243
+ ```
244
+
245
+ ## 快速开始
246
+
247
+ ### 初始化存储
248
+
249
+ ```python
250
+ from fiuai_s3 import ObjectStorageFactory
251
+
252
+ # 初始化MinIO存储
253
+ 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
261
+ )
262
+
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
+ ```
274
+
275
+ ### 使用存储实例
276
+
277
+ ```python
278
+ # 获取存储实例
279
+ storage = ObjectStorageFactory.get_instance()
280
+
281
+ # 上传文件
282
+ storage.upload_file("test.txt", b"Hello World")
283
+
284
+ # 下载文件
285
+ data = storage.download_file("test.txt")
286
+
287
+ # 删除文件
288
+ storage.delete_file("test.txt")
289
+
290
+ # 列出文件
291
+ files = storage.list_files(prefix="test/")
292
+ ```
293
+
294
+ ## 配置参数
295
+
296
+ | 参数 | 类型 | 必填 | 默认值 | 说明 |
297
+ |------|------|------|--------|------|
298
+ | provider | str | 是 | - | 存储提供商,支持 "alicloud" 或 "minio" |
299
+ | bucket_name | str | 是 | - | 存储桶名称 |
300
+ | endpoint | str | 是 | - | 存储服务端点 |
301
+ | access_key | str | 是 | - | 访问密钥 |
302
+ | secret_key | str | 是 | - | 密钥 |
303
+ | temp_dir | str | 否 | "temp/" | 临时目录 |
304
+ | use_https | bool | 否 | False | 是否使用HTTPS |
305
+
306
+ ## 开发
307
+
308
+ ### 安装开发依赖
309
+
310
+ ```bash
311
+ pip install -r requirements.txt
312
+ ```
313
+
314
+ ### 运行测试
315
+
316
+ ```bash
317
+ python -m pytest tests/
318
+ ```
319
+
320
+ ## 许可证
321
+
322
+ MIT License
323
+
324
+ ## 作者
325
+
326
+ - liming (lmlala@aliyun.com)
327
+
328
+ ## 贡献
329
+
330
+ 欢迎提交 Issue 和 Pull Request!
@@ -0,0 +1,105 @@
1
+ # FiuAI S3
2
+
3
+ 一个支持阿里云OSS和MinIO的对象存储抽象包,提供了统一的接口来操作不同的对象存储服务。
4
+
5
+ ## 特性
6
+
7
+ - 支持阿里云OSS和MinIO存储服务
8
+ - 统一的接口设计
9
+ - 工厂模式实现,易于扩展
10
+ - 完整的类型提示
11
+ - 详细的日志记录
12
+ - 异常处理机制
13
+
14
+ ## 安装
15
+
16
+ ```bash
17
+ pip install fiuai-s3
18
+ ```
19
+
20
+ ## 快速开始
21
+
22
+ ### 初始化存储
23
+
24
+ ```python
25
+ from fiuai_s3 import ObjectStorageFactory
26
+
27
+ # 初始化MinIO存储
28
+ 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
36
+ )
37
+
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
+ ```
49
+
50
+ ### 使用存储实例
51
+
52
+ ```python
53
+ # 获取存储实例
54
+ storage = ObjectStorageFactory.get_instance()
55
+
56
+ # 上传文件
57
+ storage.upload_file("test.txt", b"Hello World")
58
+
59
+ # 下载文件
60
+ data = storage.download_file("test.txt")
61
+
62
+ # 删除文件
63
+ storage.delete_file("test.txt")
64
+
65
+ # 列出文件
66
+ files = storage.list_files(prefix="test/")
67
+ ```
68
+
69
+ ## 配置参数
70
+
71
+ | 参数 | 类型 | 必填 | 默认值 | 说明 |
72
+ |------|------|------|--------|------|
73
+ | provider | str | 是 | - | 存储提供商,支持 "alicloud" 或 "minio" |
74
+ | bucket_name | str | 是 | - | 存储桶名称 |
75
+ | endpoint | str | 是 | - | 存储服务端点 |
76
+ | access_key | str | 是 | - | 访问密钥 |
77
+ | secret_key | str | 是 | - | 密钥 |
78
+ | temp_dir | str | 否 | "temp/" | 临时目录 |
79
+ | use_https | bool | 否 | False | 是否使用HTTPS |
80
+
81
+ ## 开发
82
+
83
+ ### 安装开发依赖
84
+
85
+ ```bash
86
+ pip install -r requirements.txt
87
+ ```
88
+
89
+ ### 运行测试
90
+
91
+ ```bash
92
+ python -m pytest tests/
93
+ ```
94
+
95
+ ## 许可证
96
+
97
+ MIT License
98
+
99
+ ## 作者
100
+
101
+ - liming (lmlala@aliyun.com)
102
+
103
+ ## 贡献
104
+
105
+ 欢迎提交 Issue 和 Pull Request!
@@ -0,0 +1,83 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "fiuai-s3"
7
+ version = "0.1.0"
8
+ description = "一个支持阿里云OSS和MinIO的对象存储抽象包"
9
+ readme = "README.md"
10
+ authors = [
11
+ {name = "liming", email = "lmlala@aliyun.com"}
12
+ ]
13
+ license = {file = "LICENSE"}
14
+ classifiers = [
15
+ "Development Status :: 3 - Alpha",
16
+ "Intended Audience :: Developers",
17
+ "License :: OSI Approved :: MIT License",
18
+ "Operating System :: OS Independent",
19
+ "Programming Language :: Python :: 3",
20
+ "Programming Language :: Python :: 3.7",
21
+ "Programming Language :: Python :: 3.8",
22
+ "Programming Language :: Python :: 3.9",
23
+ "Programming Language :: Python :: 3.10",
24
+ ]
25
+ requires-python = ">=3.7"
26
+ dependencies = [
27
+ "pydantic>=1.8.0",
28
+ "oss2>=2.15.0",
29
+ "minio>=7.1.0",
30
+ "hatch>=1.7.0",
31
+ ]
32
+
33
+ [project.urls]
34
+ Homepage = "https://github.com/fiuai-sz/fiuai-s3"
35
+ Repository = "https://github.com/fiuai-sz/fiuai-s3.git"
36
+
37
+ [tool.hatch.build.targets.wheel]
38
+ packages = ["src/fiuai_s3"]
39
+
40
+ [tool.hatch.build.targets.sdist]
41
+ include = [
42
+ "src/fiuai_s3",
43
+ "LICENSE",
44
+ "README.md",
45
+ ]
46
+
47
+ [tool.hatch.envs.default]
48
+ dependencies = [
49
+ "pytest>=7.0",
50
+ "pytest-cov>=4.0",
51
+ "black>=23.0",
52
+ "isort>=5.0",
53
+ "mypy>=1.0",
54
+ ]
55
+
56
+ [tool.hatch.envs.default.scripts]
57
+ test = "pytest {args:tests}"
58
+ test-cov = "pytest --cov-report=term-missing --cov-config=pyproject.toml --cov=fiuai_s3 {args:tests}"
59
+ lint = [
60
+ "black --check .",
61
+ "isort --check .",
62
+ "mypy .",
63
+ ]
64
+ fmt = [
65
+ "black .",
66
+ "isort .",
67
+ ]
68
+
69
+ [tool.black]
70
+ line-length = 100
71
+ target-version = ["py37"]
72
+
73
+ [tool.isort]
74
+ profile = "black"
75
+ line_length = 100
76
+ multi_line_output = 3
77
+
78
+ [tool.mypy]
79
+ python_version = "3.7"
80
+ warn_return_any = true
81
+ warn_unused_configs = true
82
+ disallow_untyped_defs = true
83
+ check_untyped_defs = true
@@ -0,0 +1,11 @@
1
+ # -- coding: utf-8 --
2
+ # Project: fiuai-s3
3
+ # Created Date: 2025-05-01
4
+ # Author: liming
5
+ # Email: lmlala@aliyun.com
6
+ # Copyright (c) 2025 FiuAI
7
+
8
+ from .object_storage import ObjectStorage, ObjectStorageFactory, StorageConfig
9
+
10
+ __version__ = "0.1.0"
11
+ __all__ = ["ObjectStorage", "ObjectStorageFactory", "StorageConfig"]
@@ -0,0 +1,10 @@
1
+ # -- coding: utf-8 --
2
+ # Project: fiuai-s3
3
+ # Created Date: 2025-05-01
4
+ # Author: liming
5
+ # Email: lmlala@aliyun.com
6
+ # Copyright (c) 2025 FiuAI
7
+
8
+ from .alicloud_storage import AliCloudStorage
9
+
10
+ __all__ = ["AliCloudStorage"]
@@ -0,0 +1,101 @@
1
+ # -- coding: utf-8 --
2
+ # Project: object_storage
3
+ # Created Date: 2025-05-01
4
+ # Author: liming
5
+ # Email: lmlala@aliyun.com
6
+ # Copyright (c) 2025 FiuAI
7
+
8
+ import os
9
+ import logging
10
+ from typing import List, Optional
11
+ import oss2
12
+ from ..object_storage import ObjectStorage, StorageConfig
13
+
14
+ logger = logging.getLogger(__name__)
15
+
16
+ # 设置oss2的日志级别为WARNING,关闭INFO级别的日志
17
+ oss2.set_stream_logger(level=logging.WARNING)
18
+
19
+ class AliCloudStorage(ObjectStorage):
20
+ """阿里云OSS存储实现"""
21
+
22
+ def __init__(self, config: StorageConfig):
23
+ """初始化阿里云OSS客户端
24
+
25
+ Args:
26
+ config: 存储配置对象
27
+ """
28
+ super().__init__(config)
29
+ self.auth = oss2.Auth(config.access_key, config.secret_key)
30
+ self.bucket = oss2.Bucket(
31
+ auth=self.auth,
32
+ endpoint=config.endpoint,
33
+ bucket_name=config.bucket_name
34
+ )
35
+
36
+ def upload_file(self, object_key: str, data: bytes) -> bool:
37
+ """上传文件到阿里云OSS
38
+
39
+ Args:
40
+ object_key: 对象存储中的key
41
+ data: 文件数据
42
+ Returns:
43
+ bool: 是否上传成功
44
+ """
45
+ try:
46
+ self.bucket.put_object(object_key, data)
47
+ logger.info(f"文件上传成功: {object_key}")
48
+ return True
49
+ except Exception as e:
50
+ logger.error(f"文件上传失败: {str(e)}")
51
+ return False
52
+
53
+ def download_file(self, object_key: str) -> bytes:
54
+ """从阿里云OSS下载文件
55
+
56
+ Args:
57
+ object_key: 对象存储中的key
58
+
59
+ Returns:
60
+ bytes: 文件内容
61
+ """
62
+ try:
63
+ return self.bucket.get_object(object_key).read()
64
+ except Exception as e:
65
+ logger.error(f"文件下载失败: {str(e)}")
66
+ return None
67
+
68
+ def delete_file(self, object_key: str) -> bool:
69
+ """删除阿里云OSS中的文件
70
+
71
+ Args:
72
+ object_key: 对象存储中的key
73
+
74
+ Returns:
75
+ bool: 是否删除成功
76
+ """
77
+ try:
78
+ self.bucket.delete_object(object_key)
79
+ logger.info(f"文件删除成功: {object_key}")
80
+ return True
81
+ except Exception as e:
82
+ logger.error(f"文件删除失败: {str(e)}")
83
+ return False
84
+
85
+ def list_files(self, prefix: Optional[str] = None) -> List[str]:
86
+ """列出阿里云OSS中的文件
87
+
88
+ Args:
89
+ prefix: 文件前缀过滤
90
+
91
+ Returns:
92
+ List[str]: 文件key列表
93
+ """
94
+ try:
95
+ files = []
96
+ for obj in oss2.ObjectIterator(self.bucket, prefix=prefix):
97
+ files.append(obj.key)
98
+ return files
99
+ except Exception as e:
100
+ logger.error(f"列出文件失败: {str(e)}")
101
+ return []
@@ -0,0 +1,10 @@
1
+ # -- coding: utf-8 --
2
+ # Project: fiuai-s3
3
+ # Created Date: 2025-05-01
4
+ # Author: liming
5
+ # Email: lmlala@aliyun.com
6
+ # Copyright (c) 2025 FiuAI
7
+
8
+ from .minio_storage import MinioStorage
9
+
10
+ __all__ = ["MinioStorage"]
@@ -0,0 +1,151 @@
1
+ # -- coding: utf-8 --
2
+ # Project: object_storage
3
+ # Created Date: 2025-05-01
4
+ # Author: liming
5
+ # Email: lmlala@aliyun.com
6
+ # Copyright (c) 2025 FiuAI
7
+
8
+ from io import BytesIO
9
+ import logging
10
+ from typing import List, Optional
11
+ from minio import Minio
12
+ from minio.error import S3Error
13
+ from ..object_storage import ObjectStorage, StorageConfig
14
+
15
+ logger = logging.getLogger(__name__)
16
+
17
+ class MinioStorage(ObjectStorage):
18
+ """MinIO存储实现"""
19
+
20
+ def __init__(self, config: StorageConfig):
21
+ """初始化MinIO客户端
22
+
23
+ Args:
24
+ config: 存储配置对象
25
+ """
26
+ super().__init__(config)
27
+
28
+ # 处理endpoint格式
29
+ endpoint = self._format_endpoint(config.endpoint)
30
+
31
+ self.client = Minio(
32
+ endpoint=endpoint,
33
+ access_key=config.access_key,
34
+ secret_key=config.secret_key,
35
+ secure=config.use_https # 是否使用HTTPS
36
+ )
37
+ self.bucket_name = config.bucket_name
38
+
39
+ # 确保bucket存在
40
+ if not self.client.bucket_exists(self.bucket_name):
41
+ self.client.make_bucket(self.bucket_name)
42
+ logger.info(f"创建bucket: {self.bucket_name}")
43
+
44
+ def _format_endpoint(self, endpoint: str) -> str:
45
+ """格式化endpoint,确保符合MinIO要求
46
+
47
+ Args:
48
+ endpoint: 原始endpoint
49
+
50
+ Returns:
51
+ str: 格式化后的endpoint
52
+
53
+ Raises:
54
+ ValueError: endpoint格式不正确
55
+ """
56
+ # 移除协议前缀
57
+ if endpoint.startswith(('http://', 'https://')):
58
+ endpoint = endpoint.split('://', 1)[1]
59
+
60
+ # 移除路径部分
61
+ endpoint = endpoint.split('/', 1)[0]
62
+
63
+ # 验证格式
64
+ if '/' in endpoint:
65
+ raise ValueError("MinIO endpoint不能包含路径,格式应为: host:port")
66
+
67
+ return endpoint
68
+
69
+ def upload_file(self, object_key: str, data: bytes) -> bool:
70
+ """上传文件到MinIO
71
+
72
+ Args:
73
+ object_key: 对象存储中的key
74
+ data: 文件数据
75
+
76
+ Returns:
77
+ bool: 是否上传成功
78
+ """
79
+ try:
80
+ self.client.put_object(
81
+ bucket_name=self.bucket_name,
82
+ object_name=object_key,
83
+ data=BytesIO(data),
84
+ length=len(data)
85
+ )
86
+ logger.info(f"文件上传成功: {object_key}")
87
+ return True
88
+ except S3Error as e:
89
+ logger.error(f"文件上传失败: {str(e)}")
90
+ return False
91
+
92
+ def download_file(self, object_key: str) -> bytes:
93
+ """从MinIO下载文件
94
+
95
+ Args:
96
+ object_key: 对象存储中的key
97
+
98
+ Returns:
99
+ bytes: 文件内容
100
+ """
101
+ try:
102
+ response = self.client.get_object(
103
+ bucket_name=self.bucket_name,
104
+ object_name=object_key
105
+ )
106
+ return response.read()
107
+ except S3Error as e:
108
+ logger.error(f"文件下载失败: {str(e)}")
109
+ return None
110
+
111
+ def delete_file(self, object_key: str) -> bool:
112
+ """删除MinIO中的文件
113
+
114
+ Args:
115
+ object_key: 对象存储中的key
116
+
117
+ Returns:
118
+ bool: 是否删除成功
119
+ """
120
+ try:
121
+ self.client.remove_object(
122
+ bucket_name=self.bucket_name,
123
+ object_name=object_key
124
+ )
125
+ logger.info(f"文件删除成功: {object_key}")
126
+ return True
127
+ except S3Error as e:
128
+ logger.error(f"文件删除失败: {str(e)}")
129
+ return False
130
+
131
+ def list_files(self, prefix: Optional[str] = None) -> List[str]:
132
+ """列出MinIO中的文件
133
+
134
+ Args:
135
+ prefix: 文件前缀过滤
136
+
137
+ Returns:
138
+ List[str]: 文件key列表
139
+ """
140
+ try:
141
+ files = []
142
+ objects = self.client.list_objects(
143
+ bucket_name=self.bucket_name,
144
+ prefix=prefix
145
+ )
146
+ for obj in objects:
147
+ files.append(obj.object_name)
148
+ return files
149
+ except S3Error as e:
150
+ logger.error(f"列出文件失败: {str(e)}")
151
+ return []
@@ -0,0 +1,181 @@
1
+ # -- coding: utf-8 --
2
+ # Project: fiuai-s3
3
+ # Created Date: 2025-05-01
4
+ # Author: liming
5
+ # Email: lmlala@aliyun.com
6
+ # Copyright (c) 2025 FiuAI
7
+
8
+ from abc import ABC, abstractmethod
9
+ from typing import Optional, List, Dict, Any
10
+ from pydantic import BaseModel, Field
11
+ import logging
12
+ from uuid import uuid4
13
+
14
+ logger = logging.getLogger(__name__)
15
+
16
+ class StorageConfig(BaseModel):
17
+ """存储配置类"""
18
+ provider: str = Field(..., description="存储提供商,支持 alicloud 或 minio")
19
+ bucket_name: str = Field(..., description="存储桶名称")
20
+ endpoint: str = Field(..., description="存储服务端点")
21
+ access_key: str = Field(..., description="访问密钥")
22
+ secret_key: str = Field(..., description="密钥")
23
+ temp_dir: str = Field("temp/", description="临时目录")
24
+ use_https: bool = Field(False, description="是否使用HTTPS")
25
+
26
+ class Config:
27
+ arbitrary_types_allowed = True
28
+
29
+ class ObjectStorage(ABC):
30
+ """对象存储抽象基类"""
31
+
32
+ def __init__(self, config: StorageConfig):
33
+ self.config = config
34
+ self._id = str(uuid4())
35
+
36
+ @abstractmethod
37
+ def upload_file(self, object_key: str, data: bytes) -> bool:
38
+ """上传文件到对象存储
39
+
40
+ Args:
41
+ object_key: 对象存储中的key
42
+ data: 文件数据
43
+
44
+ Returns:
45
+ bool: 是否上传成功
46
+ """
47
+ pass
48
+
49
+ @abstractmethod
50
+ def download_file(self, object_key: str) -> bytes:
51
+ """从对象存储下载文件
52
+
53
+ Args:
54
+ object_key: 对象存储中的key
55
+
56
+ Returns:
57
+ bytes: 文件数据
58
+ """
59
+ pass
60
+
61
+ @abstractmethod
62
+ def delete_file(self, object_key: str) -> bool:
63
+ """删除对象存储中的文件
64
+
65
+ Args:
66
+ object_key: 对象存储中的key
67
+
68
+ Returns:
69
+ bool: 是否删除成功
70
+ """
71
+ pass
72
+
73
+ @abstractmethod
74
+ def list_files(self, prefix: Optional[str] = None) -> List[str]:
75
+ """列出对象存储中的文件
76
+
77
+ Args:
78
+ prefix: 文件前缀过滤
79
+
80
+ Returns:
81
+ List[str]: 文件key列表
82
+ """
83
+ pass
84
+
85
+ class ObjectStorageFactory:
86
+ """对象存储工厂类"""
87
+
88
+ _instance: Optional[ObjectStorage] = None
89
+ _config: Optional[StorageConfig] = None
90
+
91
+ @classmethod
92
+ def initialize(cls,
93
+ provider: str = "minio",
94
+ bucket_name: str = "dev",
95
+ endpoint: str = "http://127.0.0.1:19000",
96
+ access_key: str = "devdevdev",
97
+ secret_key: str = "devdevdev",
98
+ temp_dir: str = "temp/",
99
+ use_https: bool = False) -> None:
100
+ """初始化对象存储配置
101
+
102
+ Args:
103
+ provider: 存储提供商,支持 alicloud 或 minio
104
+ bucket_name: 存储桶名称
105
+ endpoint: 存储服务端点
106
+ access_key: 访问密钥
107
+ secret_key: 密钥
108
+ temp_dir: 临时目录
109
+ use_https: 是否使用HTTPS
110
+ """
111
+ cls._config = StorageConfig(
112
+ provider=provider,
113
+ bucket_name=bucket_name,
114
+ endpoint=endpoint,
115
+ access_key=access_key,
116
+ secret_key=secret_key,
117
+ temp_dir=temp_dir,
118
+ use_https=use_https
119
+ )
120
+ cls._instance = None
121
+
122
+ @classmethod
123
+ def get_instance(cls) -> ObjectStorage:
124
+ """获取对象存储单例实例
125
+
126
+ Returns:
127
+ ObjectStorage: 对象存储实例
128
+
129
+ Raises:
130
+ ValueError: 未初始化配置或不支持的存储提供商
131
+ """
132
+ if cls._config is None:
133
+ raise ValueError("请先调用 initialize() 方法初始化配置")
134
+
135
+ if cls._instance is None:
136
+ provider = cls._config.provider.lower()
137
+
138
+ if provider == "alicloud":
139
+ from .alicloud.alicloud_storage import AliCloudStorage
140
+ cls._instance = AliCloudStorage(cls._config)
141
+ logger.info(f"已初始化阿里云对象存储实例")
142
+ elif provider == "minio":
143
+ from .minio.minio_storage import MinioStorage
144
+ cls._instance = MinioStorage(cls._config)
145
+ logger.info(f"已初始化MinIO对象存储实例")
146
+ else:
147
+ raise ValueError(f"不支持的存储提供商: {provider}")
148
+
149
+ return cls._instance
150
+
151
+ @classmethod
152
+ def create_storage(cls, config: StorageConfig) -> ObjectStorage:
153
+ """创建新的对象存储实例
154
+
155
+ Args:
156
+ config: 存储配置对象
157
+
158
+ Returns:
159
+ ObjectStorage: 对象存储实例
160
+
161
+ Raises:
162
+ ValueError: 不支持的存储提供商
163
+ """
164
+ provider = config.provider.lower()
165
+
166
+ if provider == "alicloud":
167
+ from .alicloud.alicloud_storage import AliCloudStorage
168
+ return AliCloudStorage(config)
169
+ elif provider == "minio":
170
+ from .minio.minio_storage import MinioStorage
171
+ return MinioStorage(config)
172
+ else:
173
+ raise ValueError(f"不支持的存储提供商: {provider}")
174
+
175
+ # 导出工厂类
176
+ __all__ = ['ObjectStorage', 'ObjectStorageFactory', 'StorageConfig']
177
+
178
+ # 创建全局对象存储实例
179
+ Storage = ObjectStorageFactory.get_instance()
180
+
181
+