working commit

This commit is contained in:
2026-02-04 22:55:48 +02:00
parent 3900d93559
commit afeab061e9
6 changed files with 117 additions and 65 deletions
+12 -1
View File
@@ -104,6 +104,7 @@ type PatchUploadParams struct {
}
type PatchUploadResult struct {
Location string
Range string
}
// The response for each successful chunk upload MUST be 202 Accepted, and MUST have the following headers:
@@ -125,6 +126,16 @@ func (oper *Operator) PatchUpload(ctx context.Context, params *PatchUploadParams
return res, http.StatusBadRequest, err
}
exists, uploadSize, err := oper.store.UploadExists(params.Name, params.Reference)
if err != nil {
return res, http.StatusInternalServerError, err
}
if exists {
res.Location = fmt.Sprintf("/v2/%s/uploads/%s", params.Name, params.Reference)
res.Range = fmt.Sprintf("0-%d", uploadSize-1)
return res, http.StatusNoContent, err
}
if params.ContentType != "application/octet-stream" {
err = fmt.Errorf("Wrong Conten-Type header: %s", params.ContentType)
return res, http.StatusBadRequest, err
@@ -150,7 +161,7 @@ func (oper *Operator) PatchUpload(ctx context.Context, params *PatchUploadParams
return res, http.StatusInternalServerError, err
}
res.Location = fmt.Sprintf("/v2/%s/uploads/%s", params.Name, params.Reference)
res.Range = fmt.Sprintf("0-%d", recsize-1)
return res, http.StatusAccepted, err
}