88 ALLOWED_CONTENT_TYPES ,
99 GALLERY_SIZE ,
1010 LIST_PAGE_SIZE ,
11- MAX_UPLOAD_BYTES ,
1211 OUTPUT_PREFIX ,
1312 STATUS_MAP ,
1413 failure_key ,
@@ -33,20 +32,13 @@ def declared_length(request: Request) -> int | None:
3332
3433@app .post ("/api/jobs" , status_code = 202 )
3534async def create_job (request : Request ) -> dict [str , str ]:
36- content_type = request .headers .get ("content-type" , "" ). split ( ";" )[ 0 ]. strip (). lower ()
37- if content_type not in ALLOWED_CONTENT_TYPES :
35+ content_type = request .headers .get ("content-type" , "" )
36+ if not content_type . startswith ( ALLOWED_CONTENT_TYPES ) :
3837 raise HTTPException (415 , "Send a raw image/png, image/jpeg or image/webp body." )
3938
40- too_long = f"Images must be at most { MAX_UPLOAD_BYTES } bytes."
41- length = declared_length (request )
42- if length is not None and length > MAX_UPLOAD_BYTES :
43- raise HTTPException (413 , too_long )
44-
4539 image = await request .body ()
4640 if not image :
4741 raise HTTPException (400 , "The request body is empty." )
48- if len (image ) > MAX_UPLOAD_BYTES :
49- raise HTTPException (413 , too_long )
5042
5143 env = request .scope ["env" ]
5244 job_id = uuid .uuid4 ().hex
@@ -151,7 +143,6 @@ async def get_image(kind: str, job_id: str, request: Request) -> Response:
151143 if obj is None :
152144 raise HTTPException (404 , "Image not found." )
153145
154- # Serve the type recorded when the bytes were stored; never guess from the key.
155146 http_metadata = obj .httpMetadata
156147 media_type = http_metadata .contentType if http_metadata is not None else None
157148 blob = await obj .blob ()
0 commit comments