Files
mstore/app/imageoper/postupload.go
T

44 lines
957 B
Go

/*
* Copyright 2026 Oleg Borodin <onborodin@gmail.com>
*/
package imageoper
import (
"context"
"fmt"
"net/http"
"strconv"
"mstore/pkg/auxuuid"
)
type PostUploadParams struct {
Name string
Digest string
Mount string
From string
}
type PostUploadResult struct {
DockerUploadUUID string
Location string
ContentLength string
}
func (oper *Operator) PostUpload(ctx context.Context, operatorID string, params *PostUploadParams) (*PostUploadResult, int, error) {
var err error
res := &PostUploadResult{}
if params.Digest == "" {
uuid := auxuuid.NewUUID()
location := fmt.Sprintf("/v2/%s/blobs/uploads/%s", params.Name, uuid)
res.DockerUploadUUID = uuid
res.Location = location
res.ContentLength = strconv.FormatInt(0, 10)
return res, http.StatusAccepted, err
} else {
err = fmt.Errorf("PostUpload: Not empty digest header")
return res, http.StatusInternalServerError, err
}
return res, http.StatusOK, err
}