本文整理汇总了Golang中github.com/containerops/dockyard/models.Image.Save方法的典型用法代码示例。如果您正苦于以下问题:Golang Image.Save方法的具体用法?Golang Image.Save怎么用?Golang Image.Save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/containerops/dockyard/models.Image
的用法示例。
在下文中一共展示了Image.Save方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: PutBlobsV2Handler
func PutBlobsV2Handler(ctx *macaron.Context, log *logs.BeeLogger) (int, []byte) {
desc := ctx.Params(":uuid")
uuid := strings.Split(desc, "?")[0]
digest := ctx.Query("digest")
tarsum := strings.Split(digest, ":")[1]
imagePathTmp := module.GetImagePath(uuid, setting.APIVERSION_V2)
layerPathTmp := module.GetLayerPath(uuid, "layer", setting.APIVERSION_V2)
imagePath := module.GetImagePath(tarsum, setting.APIVERSION_V2)
layerPath := module.GetLayerPath(tarsum, "layer", setting.APIVERSION_V2)
reqbody, _ := ctx.Req.Body().Bytes()
layerlen, err := module.SaveLayerLocal(imagePathTmp, layerPathTmp, imagePath, layerPath, reqbody)
if err != nil {
log.Error("[REGISTRY API V2] Failed to save layer %v: %v", layerPath, err.Error())
result, _ := json.Marshal(map[string]string{"message": "Failed to save layer file"})
return http.StatusInternalServerError, result
}
//saving specific tarsum every times is in order to split the same tarsum in HEAD handler
i := new(models.Image)
i.Path, i.Size = layerPath, int64(layerlen)
if err := i.Save(tarsum); err != nil {
log.Error("[REGISTRY API V2] Failed to save tarsum %v: %v", tarsum, err.Error())
result, _ := json.Marshal(map[string]string{"message": "Failed to save tarsum"})
return http.StatusBadRequest, result
}
random := fmt.Sprintf("%s://%s/v2/%s/%s/blobs/%s",
setting.ListenMode,
setting.Domains,
ctx.Params(":namespace"),
ctx.Params(":repository"),
digest)
ctx.Resp.Header().Set("Content-Type", "text/plain; charset=utf-8")
ctx.Resp.Header().Set("Docker-Content-Digest", digest)
ctx.Resp.Header().Set("Location", random)
result, _ := json.Marshal(map[string]string{})
return http.StatusCreated, result
}