//AppcPutASCV1Handler is func AppcPutASCV1Handler(ctx *macaron.Context) (int, []byte) { namespace := ctx.Params(":namespace") repository := ctx.Params(":repository") version := ctx.Params(":version") aci := ctx.Params(":aci") r := new(models.AppcV1) if err := r.Get(namespace, repository); err != nil { log.Errorf("[%s] get AppcV1 repository error: %s", ctx.Req.RequestURI, err.Error()) result, _ := json.Marshal(map[string]string{"message": "Get Appc Repository Error."}) return http.StatusBadRequest, result } basePath := setting.AppcStorage imagePath := fmt.Sprintf("%s/%s/%s/%s", basePath, namespace, repository, version) filePath := fmt.Sprintf("%s/%s.asc", imagePath, aci) if !utils.IsDirExist(imagePath) { os.MkdirAll(imagePath, os.ModePerm) } if _, err := os.Stat(filePath); err == nil { os.Remove(filePath) } if file, err := os.Create(filePath); err != nil { log.Errorf("[%s] Create asc file error:%s", ctx.Req.RequestURI, err.Error()) result, _ := json.Marshal(map[string]string{"message": "Create .asc File Error."}) return http.StatusBadRequest, result } else { io.Copy(file, ctx.Req.Request.Body) } i := new(models.ACIv1) if err := i.PutSign(r.ID, version, aci, filePath); err != nil { log.Errorf("[%s] write sign{.asc} data error: %s", ctx.Req.RequestURI, err.Error()) result, _ := json.Marshal(map[string]string{"message": "Write .asc data Error."}) return http.StatusBadRequest, result } result, _ := json.Marshal(map[string]string{}) return http.StatusOK, result }