feat(api): lab5 serve attachment variants in json and content endpoints

This commit is contained in:
Голиков Maximillian Антон
2026-11-09 14:51:17 +03:00
parent 22c876f63c
commit bb5f2fb237
4 changed files with 27 additions and 8 deletions
+11 -1
View File
@@ -31,7 +31,17 @@ type AttachmentResponse struct {
}
func AttachmentFromDomain(a *domain.Attachment) AttachmentResponse {
variants := make([]VariantResponse, 0)
variants := make([]VariantResponse, len(a.Variants))
for i, v := range a.Variants {
variants[i] = VariantResponse{
Name: v.Name,
ContentType: v.ContentType,
SizeBytes: v.SizeBytes,
Width: v.Width,
Height: v.Height,
SHA256: hex.EncodeToString(v.SHA256),
}
}
errCode := a.ErrorCode
return AttachmentResponse{
ID: a.ID,