Implement backend upload/download API enhancements
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
from datetime import datetime
|
||||
from typing import Optional, List, Generic, TypeVar
|
||||
from typing import Optional, List, Dict, Any, Generic, TypeVar
|
||||
from pydantic import BaseModel
|
||||
from uuid import UUID
|
||||
|
||||
@@ -66,6 +66,7 @@ class ArtifactResponse(BaseModel):
|
||||
created_at: datetime
|
||||
created_by: str
|
||||
ref_count: int
|
||||
format_metadata: Optional[Dict[str, Any]] = None
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
@@ -96,6 +97,53 @@ class UploadResponse(BaseModel):
|
||||
project: str
|
||||
package: str
|
||||
tag: Optional[str]
|
||||
format_metadata: Optional[Dict[str, Any]] = None
|
||||
deduplicated: bool = False
|
||||
|
||||
|
||||
# Resumable upload schemas
|
||||
class ResumableUploadInitRequest(BaseModel):
|
||||
"""Request to initiate a resumable upload"""
|
||||
expected_hash: str # SHA256 hash of the file (client must compute)
|
||||
filename: str
|
||||
content_type: Optional[str] = None
|
||||
size: int
|
||||
tag: Optional[str] = None
|
||||
|
||||
|
||||
class ResumableUploadInitResponse(BaseModel):
|
||||
"""Response from initiating a resumable upload"""
|
||||
upload_id: Optional[str] # None if file already exists
|
||||
already_exists: bool
|
||||
artifact_id: Optional[str] = None # Set if already_exists is True
|
||||
chunk_size: int # Recommended chunk size for parts
|
||||
|
||||
|
||||
class ResumableUploadPartResponse(BaseModel):
|
||||
"""Response from uploading a part"""
|
||||
part_number: int
|
||||
etag: str
|
||||
|
||||
|
||||
class ResumableUploadCompleteRequest(BaseModel):
|
||||
"""Request to complete a resumable upload"""
|
||||
tag: Optional[str] = None
|
||||
|
||||
|
||||
class ResumableUploadCompleteResponse(BaseModel):
|
||||
"""Response from completing a resumable upload"""
|
||||
artifact_id: str
|
||||
size: int
|
||||
project: str
|
||||
package: str
|
||||
tag: Optional[str]
|
||||
|
||||
|
||||
class ResumableUploadStatusResponse(BaseModel):
|
||||
"""Status of a resumable upload"""
|
||||
upload_id: str
|
||||
uploaded_parts: List[int]
|
||||
total_uploaded_bytes: int
|
||||
|
||||
|
||||
# Consumer schemas
|
||||
|
||||
Reference in New Issue
Block a user