mirror of
https://github.com/minio/minio.git
synced 2025-11-11 06:20:14 -05:00
Implement heal-upload admin API (#3914)
This API is meant for administrative tools like mc-admin to heal an ongoing multipart upload on a Minio server. N B This set of admin APIs apply only for Minio servers. `github.com/minio/minio/pkg/madmin` provides a go SDK for this (and other admin) operations. Specifically, func HealUpload(bucket, object, uploadID string, dryRun bool) error Sample admin API request: POST /?heal&bucket=mybucket&object=myobject&upload-id=myuploadID&dry-run - Header(s): ["x-minio-operation"] = "upload" Notes: - bucket, object and upload-id are mandatory query parameters - if dry-run is set, API returns success if all parameters passed are valid.
This commit is contained in:
committed by
Harshavardhana
parent
d4eea224d4
commit
c192e5c9b2
@@ -231,6 +231,7 @@ const (
|
||||
healDryRun healQueryKey = "dry-run"
|
||||
healUploadIDMarker healQueryKey = "upload-id-marker"
|
||||
healMaxUpload healQueryKey = "max-uploads"
|
||||
healUploadID healQueryKey = "upload-id"
|
||||
)
|
||||
|
||||
// mkHealQueryVal - helper function to construct heal REST API query params.
|
||||
@@ -432,6 +433,43 @@ func (adm *AdminClient) HealBucket(bucket string, dryrun bool) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// HealUpload - Heal the given upload.
|
||||
func (adm *AdminClient) HealUpload(bucket, object, uploadID string, dryrun bool) error {
|
||||
// Construct query params.
|
||||
queryVal := url.Values{}
|
||||
queryVal.Set("heal", "")
|
||||
queryVal.Set(string(healBucket), bucket)
|
||||
queryVal.Set(string(healObject), object)
|
||||
queryVal.Set(string(healUploadID), uploadID)
|
||||
if dryrun {
|
||||
queryVal.Set(string(healDryRun), "")
|
||||
}
|
||||
|
||||
hdrs := make(http.Header)
|
||||
hdrs.Set(minioAdminOpHeader, "upload")
|
||||
|
||||
reqData := requestData{
|
||||
queryValues: queryVal,
|
||||
customHeaders: hdrs,
|
||||
}
|
||||
|
||||
// Execute POST on
|
||||
// /?heal&bucket=mybucket&object=myobject&upload-id=uploadID
|
||||
// to heal an upload.
|
||||
resp, err := adm.executeMethod("POST", reqData)
|
||||
|
||||
defer closeResponse(resp)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return httpRespToErrorResponse(resp)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// HealObject - Heal the given object.
|
||||
func (adm *AdminClient) HealObject(bucket, object string, dryrun bool) error {
|
||||
// Construct query params.
|
||||
|
||||
Reference in New Issue
Block a user