working commit
This commit is contained in:
+12
-1
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user