init
This commit is contained in:
commit
4e82a5615e
14
.gitignore
vendored
Normal file
14
.gitignore
vendored
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
node_modules
|
||||||
|
.env
|
||||||
|
.env.local
|
||||||
|
.env.development
|
||||||
|
.env.production
|
||||||
|
.env.test
|
||||||
|
.env.test.local
|
||||||
|
.env.test.development
|
||||||
|
.env.test.production
|
||||||
|
.cursor
|
||||||
|
.vscode
|
||||||
|
.git
|
||||||
|
__pycache__
|
||||||
|
front/前端aichat组件prompt.md
|
1
front
Submodule
1
front
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit e3cb2c2ab8d1ea429c7f5b645eda872e3d1d8f14
|
83
server/app.py
Normal file
83
server/app.py
Normal file
File diff suppressed because it is too large
Load Diff
417
server/hospital.py
Normal file
417
server/hospital.py
Normal file
File diff suppressed because it is too large
Load Diff
562
server/image.py
Normal file
562
server/image.py
Normal file
File diff suppressed because it is too large
Load Diff
180
server/login.py
Normal file
180
server/login.py
Normal file
File diff suppressed because it is too large
Load Diff
279
server/models.py
Normal file
279
server/models.py
Normal file
File diff suppressed because it is too large
Load Diff
95
server/user.py
Normal file
95
server/user.py
Normal file
File diff suppressed because it is too large
Load Diff
126
server/utils/jwtauth.py
Normal file
126
server/utils/jwtauth.py
Normal file
File diff suppressed because it is too large
Load Diff
37
server/utils/oss.py
Normal file
37
server/utils/oss.py
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
import oss2
|
||||||
|
import os
|
||||||
|
|
||||||
|
access_key_id = 'LTAI5tHP6zqRhFLCkbCcZ2t1'
|
||||||
|
access_key_secret = 'VdZs0WNoUvi1zrIpvCnQ4Sk2kJMVa7'
|
||||||
|
bucket_name = 'emberauthor'
|
||||||
|
custom_endpoint = 'https://cdn.ember.ac.cn'
|
||||||
|
|
||||||
|
# 创建认证对象
|
||||||
|
auth = oss2.Auth(access_key_id, access_key_secret)
|
||||||
|
|
||||||
|
# 创建 Bucket 对象
|
||||||
|
bucket = oss2.Bucket(auth, custom_endpoint, bucket_name, is_cname=True)
|
||||||
|
|
||||||
|
def upload_to_oss(file_storage, object_name):
|
||||||
|
"""
|
||||||
|
将文件上传到阿里云OSS。
|
||||||
|
|
||||||
|
:param file_storage: Flask 请求中的 FileStorage 对象或文件流
|
||||||
|
:param object_name: 在 OSS 上存储的对象名称 (e.g., 'images/my-photo.jpg')
|
||||||
|
:return: 上传成功则返回文件URL,否则返回None
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
# 使用 put_object 方法上传文件流
|
||||||
|
result = bucket.put_object(object_name, file_storage)
|
||||||
|
|
||||||
|
# 如果HTTP状态码是200,说明上传成功
|
||||||
|
if result.status == 200:
|
||||||
|
# 构建文件的公开访问URL
|
||||||
|
file_url = f"{custom_endpoint}/{object_name}"
|
||||||
|
return file_url
|
||||||
|
else:
|
||||||
|
print(f"OSS upload failed with status: {result.status}")
|
||||||
|
return None
|
||||||
|
except oss2.exceptions.OssError as e:
|
||||||
|
print(f"Error uploading to OSS: {e}")
|
||||||
|
return None
|
Loading…
x
Reference in New Issue
Block a user