forked from mtusi2026/mtusi2026lab4
fix(attachment): check download variant and readiness
This commit is contained in:
@@ -113,8 +113,19 @@ func (h *AttachmentHandler) GetContent(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
req := dto.GetAttachmentContentRequest{
|
||||
Variant: r.URL.Query().Get("variant"),
|
||||
}
|
||||
if !req.Validate() {
|
||||
httpx.WriteError(w, http.StatusNotFound, dto.ErrorCodeNotFound, "not found", requestID)
|
||||
return
|
||||
}
|
||||
|
||||
data, contentType, err := h.service.GetContent(r.Context(), userID, attachmentID)
|
||||
switch {
|
||||
case errors.Is(err, service.ErrAttachmentNotReady):
|
||||
httpx.WriteError(w, http.StatusConflict, dto.ErrorCodeConflict, "attachment not ready", requestID)
|
||||
return
|
||||
case errors.Is(err, service.ErrAttachmentNotFound):
|
||||
httpx.WriteError(w, http.StatusNotFound, dto.ErrorCodeNotFound, "not found", requestID)
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user