The Pre-Signed URL pattern allows clients to upload or download files directly
to/from object storage (S3), without transiting through the application server.
The server generates a cryptographically signed temporary URL with constraints
(MIME type, max size, expiration).
In Granit, this pattern is at the core of Granit.BlobStorage with a
Direct-to-Cloud architecture, a post-upload validation pipeline, and a
GDPR-compliant crypto-shredding mechanism.
sequenceDiagram
participant C as Client
participant API as Granit API
participant S3 as S3 in Europe
participant V as Validation Pipeline
participant DB as BlobDescriptorStore
Note over C,DB: Phase 1 -- Initiation
C->>API: InitiateUploadAsync("medical-docs", request)
API->>DB: Create BlobDescriptor (Status = Pending)
API->>S3: Generate PUT Pre-Signed URL
API-->>C: PresignedUploadTicket (URL + expiry)
Note over C,S3: Phase 2 -- Direct upload
C->>S3: PUT {presignedUrl} [binary file]
Note over C,S3: The application server is not involved
Note over S3,DB: Phase 3 -- Validation
S3-->>V: Notification (SNS/webhook)
V->>V: MagicBytesValidator (Order=10)
V->>V: MaxSizeValidator (Order=20)
alt Validation passed
V->>DB: Status = Valid
else Validation failed
V->>DB: Status = Rejected
end
Note over C,DB: Phase 4 -- Download
C->>API: CreateDownloadUrlAsync("medical-docs", blobId)
API->>DB: Check Status = Valid
API->>S3: Generate GET Pre-Signed URL
API-->>C: PresignedDownloadUrl (URL + expiry)
C->>S3: GET {presignedUrl}