Zeitüberschreitungsfehler beim Hochladen großer Datei in FastapiPython

Python-Programme
Guest
 Zeitüberschreitungsfehler beim Hochladen großer Datei in Fastapi

Post by Guest »

Ich habe eine Fastapi -Funktion, die eine Datei empfängt, sie lokal speichert, sie entrichtet und das unberechtigte Bild an einen artifaktorischen Ort drückt. Aus irgendeinem Grund werden größere Dateien oder manchmal kleinere Dateien zeitlich festgelegt, während Sie mit einer 200 -Code> -Antwort hochladen. Ich habe alle Vorschläge wie nginx ohne Glück gefolgt.

Code: Select all

 @router.post("/upload_container")
async def post_container(file: UploadFile = File(), new_container_image: str = Form(), new_tag: str = Form()):
if file.content_type != "application/x-tar":
raise HTTPException(status_code=400, detail="Can only accept tarred version of Docker file")
file_path = str(str(uuid.uuid4()).split("-")[1]) + ".tar"
async with aiofiles.open(file_path, "wb") as out_file:
while content := await file.read(1024):  # async read chunk
await out_file.write(content)  # async write chunk
file_path = str(os.path.abspath(os.path.join(os.getcwd(), file_path)))
command = "podman load --input {}".format(file_path)
result = subprocess.run(split(command), stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
if result.returncode != 0:
return {"filename": file.filename, "details": result.stderr, "Error": {" failed to unwrap"}}
tagged_image = str(str(result.stdout).split("\n")[0]).split("Loaded image(s):")[1]
if os.path.exists(file_path):
os.remove(file_path)
if tagandpull(tagged_image, new_container_image, new_tag) != True:
return {"message": "Unable to push the image", "image_name": f"{file.filename}"}
return {
"filename": file.filename,
"Details": {
"new_url": "artifactorylocation.cloud.com/"
+ config_data.output["repos"]["local"]["deploy_repo"]
+ "/"
+ new_container_image,
"new_tag": new_tag,
},
}
< /code>
Hier ist meine nginx -Annotation: < /p>
  annotations: {
'kubernetes.io/ingress.class': 'nginx',
'nginx.ingress.kubernetes.io/proxy-body-size': '2400m',
'nginx.ingress.kubernetes.io/proxy-connect-timeout': '600',
'nginx.ingress.kubernetes.io/proxy-read-timeout': '600',
'nginx.ingress.kubernetes.io/proxy-send-timeout': '600'
},
Hat jemand vor diesem Problem konfrontiert?

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post