Spaces:
Sleeping
Sleeping
Commit
·
bd75c69
1
Parent(s):
403ee22
fix: wrong request object type/schema
Browse files
app.py
CHANGED
@@ -2,7 +2,7 @@ from http import HTTPStatus
|
|
2 |
import os, io, base64
|
3 |
import uvicorn
|
4 |
import logging
|
5 |
-
from fastapi import FastAPI, File, HTTPException, Header, UploadFile
|
6 |
from apis.s3 import S3
|
7 |
from dotenv import load_dotenv
|
8 |
from models.response import Response
|
@@ -101,9 +101,9 @@ async def upload(
|
|
101 |
async def upload2(
|
102 |
x_request_user: str = Header(...),
|
103 |
x_api_key: str = Header(...),
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
file: UploadFile = File(...)
|
108 |
):
|
109 |
res = Response()
|
@@ -115,7 +115,7 @@ async def upload2(
|
|
115 |
res.status = HTTPStatus.FORBIDDEN
|
116 |
res.error = "Invalid credentials"
|
117 |
else:
|
118 |
-
key = f'{
|
119 |
logging.info(f'Key for S3 upload: {key}')
|
120 |
|
121 |
try:
|
@@ -132,7 +132,7 @@ async def upload2(
|
|
132 |
res.error = str(e)
|
133 |
logging.warning(f"Error during upload: {res.error}")
|
134 |
|
135 |
-
res.data =
|
136 |
return res
|
137 |
|
138 |
def is_valid(u, p):
|
|
|
2 |
import os, io, base64
|
3 |
import uvicorn
|
4 |
import logging
|
5 |
+
from fastapi import FastAPI, File, Form, HTTPException, Header, UploadFile
|
6 |
from apis.s3 import S3
|
7 |
from dotenv import load_dotenv
|
8 |
from models.response import Response
|
|
|
101 |
async def upload2(
|
102 |
x_request_user: str = Header(...),
|
103 |
x_api_key: str = Header(...),
|
104 |
+
job_no: str = Form(...),
|
105 |
+
s3key: str = Form(...),
|
106 |
+
ref: str = Form(...),
|
107 |
file: UploadFile = File(...)
|
108 |
):
|
109 |
res = Response()
|
|
|
115 |
res.status = HTTPStatus.FORBIDDEN
|
116 |
res.error = "Invalid credentials"
|
117 |
else:
|
118 |
+
key = f'{s3key}/{job_no}/{file.name}'
|
119 |
logging.info(f'Key for S3 upload: {key}')
|
120 |
|
121 |
try:
|
|
|
132 |
res.error = str(e)
|
133 |
logging.warning(f"Error during upload: {res.error}")
|
134 |
|
135 |
+
res.data = ref
|
136 |
return res
|
137 |
|
138 |
def is_valid(u, p):
|