async def __postprocess__(img_file: ImagePng, context: EventContext, *, response: PostprocessHook) -> str: response.set_header("Content-Disposition", f"attachment; filename={img_file.file_name}") response.set_content_type(img_file.content_type) response.set_file_response(path=img_file.file_path) return img_file.file_name
async def __postprocess__(path: str, context: EventContext, *, response: PostprocessHook) -> str: file_name = Path(path).name response.set_header("Content-Disposition", f"attachment; filename={file_name}") response.set_header("Content-Type", 'text/plain') response.set_file_response(path=path) return path
async def __postprocess__(img_file: ImagePng, context: EventContext, response: PostprocessHook) -> str: if os.path.isfile(img_file.file_path): response.set_header('Content-Disposition', f'attachment; filename="{img_file.file_name}"') response.set_content_type(img_file.content_type) response.set_file_response(img_file.file_path) return f"File {img_file.file_name}" response.set_status(400) return f"File {img_file.file_name} not found"