Introduced two Pydantic models: `PresignedUrlRequest` and `PresignedUrlResponse`. These define the request and response structures for presigned URL generation, including fields for filenames, content types, and expiration details. This provides a clear contract for handling presigned URL functionality.
25 lines
965 B
Python
25 lines
965 B
Python
from pydantic import BaseModel, Field
|
|
|
|
|
|
class PresignedUrlRequest(BaseModel):
|
|
"""Request model for generating presigned URLs."""
|
|
filename: str = Field(..., description="Original filename of the image")
|
|
content_type: str = Field(..., description="Content type of the file (e.g., image/jpeg)")
|
|
folder: str = Field("images", description="Folder to store the file in")
|
|
|
|
class Config:
|
|
schema_extra = {
|
|
"example": {
|
|
"filename": "my-image.jpg",
|
|
"content_type": "image/jpeg",
|
|
"folder": "event-themes"
|
|
}
|
|
}
|
|
|
|
|
|
class PresignedUrlResponse(BaseModel):
|
|
"""Response model for presigned URL generation."""
|
|
upload_url: str = Field(..., description="URL to upload the file to")
|
|
file_url: str = Field(..., description="URL where the file will be accessible after upload")
|
|
expires_in: int = Field(..., description="Time in seconds until the upload URL expires")
|