upload_oview.py
1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# coding=utf-8
#author: 4N
#createtime: 2021/9/17
#email: nheweijun@sina.com
from app.util.component.ApiTemplate import ApiTemplate
import os
from flask import request
import uuid
import configure
class Api(ApiTemplate):
api_name = "上传缩略图"
def process(self):
# 返回结果
res = {}
try:
# 业务逻辑
dir_path = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))),"overview")
file = request.files['file']
gid = uuid.uuid1().__str__()
filename = file.filename.split('"')[0]
store_file = os.path.join(dir_path, "{}{}".format(gid,filename))
file.save(store_file)
res["data"] ="http://{}/API/Service/Overview/{}".format(
configure.deploy_ip_host, "{}{}".format(gid,filename))
res["result"] = True
except Exception as e:
raise e
return res
api_doc = {
"tags": ["切片服务接口"],
"parameters": [
{"name": "file",
"in": "formData",
"type": "file",
"description": "缩略图"},
],
"responses": {
200: {
"schema": {
"properties": {
}
}
}
}
}